cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RichardB Advocate III
Advocate III

Remove image from CDS

Hello, have been successful in Patching a photo to a CDS image field, however I can't work out how to delete it or remove it from the record.

 

Is anyone able to provide a solution to this?

 

Thanks Richard

20 REPLIES 20
tofsweden Helper II
Helper II

Re: Remove image from CDS

Create a flow that reads in your cds entity and then delete the chosen attribute (if you choose primaryid then you'll wipe it all)

RichardB Advocate III
Advocate III

Re: Remove image from CDS

Hi tofsweden,

Thanks for responding, however I don't really undersand your suggestion, are you able to provide any more information?

 

regards Richard

hpkeong Community Champion
Community Champion

Re: Remove image from CDS

Hi

 

If you can save, then you should be able to delete.

Save:

Patch(DS, Defaults(DS), {Fields...{)

 

Delete:

Remove(DS, ThisItem)...make sure it is placed within the Gallery and for each record.

(This is to delete single items).

 

Hope this helps.

hpkeong
RichardB Advocate III
Advocate III

Re: Remove image from CDS

Hi hpkeong,

 

Thanks for responding.

 

I understand that the Remove function will remove(delete) the complerte record, which is fine,, but I am interested in removing only the image and leaving the remainder of the record intact.

 

The documentation states that the UpdateIf function and Patch functions can update specific fields in a record, so I was wondering how they might be used to 'remove/delete' the image contents

 

thanks Richard

hpkeong Community Champion
Community Champion

Re: Remove image from CDS

Hi

 

Alright, you are referring to a particular "Value" a "A record".

 

Please follow this step as "one of the option":

- Insert a Button / Trash Icon in the gallery, and it will appear in each record.

- Please set the formula to:

  UpdateIf(DS, FieldTitle1 = ThisItem.FieldTitle1, {ImageField: ""})

 

It means:

Update DS, if FieldTitle1 is equivalent to the This Item's Field Title, Then replace ImageField with Empty records.

 

NB: Please take note, FieldTitle1 = ThisItem.FieldTitle1 must be from a UNIQUE No. Otherwise, those with similar FieldTitle1 will be deleted at the same time. Please be careful

 

Hope this helps.

https://powerapps.microsoft.com/en-us/tutorials/function-update-updateif/

 

UpdateIf function

Use the UpdateIf function to modify one or more values in one or more records that match one or more conditions. The condition can be any formula that results in a true or false and can reference columns of the data source by name. The function evaluates the condition for each record and modifies any record for which the result is true.

To specify a modification, use a change record that contains new property values. If you provide this change record inline with curly braces, property formulas can reference properties of the record that's being modified. You can use this behavior to modify records based on a formula

 

Sample screenshot is my demo and it works as explained.

 

Screenshot (273).pngUse UpdateIf 

hpkeong
hpkeong Community Champion
Community Champion

Re: Remove image from CDS

Hi

 

Additionally, if you wish to Delete ALL the IMAGES from ALL the records,

you can have:

UpdateIf(DS,  true, {ImageField: "" } )

hpkeong
RichardB Advocate III
Advocate III

Re: Remove image from CDS

Hi there,

 

Unfortunately, this didn't work and I got an error saying the field is expecting a URL and not an empty string ("")

I believe your solution will work for text/string based fields, however I think this is the same issue as trying to Patch a Null value to a date field in the CDS.

 

It would be good to get some comments from the PowerApps tech team as to whether it is currently possible to Patch a null value to any data types in the CDS.

 

As an experiment I exported the entity to Excel and then substituted the URL string with [Null] and then Imported back and the image was no longer visible in the gallery!

 

Thanks for you assistance so far

 

Richard

 

 

hpkeong Community Champion
Community Champion

Re: Remove image from CDS

Hi @RichardB

 

Sorry for not being able to help due to my limited knowledge in PowerApps.

Thanks.

 

hpkeong
RichardB Advocate III
Advocate III

Re: Remove image from CDS

Hi @hpkeong

 

I have followed many of your previous solutions and they have been very helpful.

 

It seems there are still some limitations with Patching null values to CDS entities, so hopefully the PA program team and CDS team are working on a solution for this... perhaps we might get a comment from them?

 

thanks Richard

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,686)