cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

Patch a CDS image column? Am I wasting my time?

I'm trying everything I can think of to update a CDS image column. Is this possible NOT using a form? I need to run this in a ForAll. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper V
Helper V

Re: Patch a CDS image column? Am I wasting my time?

Thank you for the response.  I actually came up with a work around that is similar to yours. I added an "updated" column to my CDS entity with default to "no". Then added a Form4 on a blank screen that won't be navigated to with just a picture and set it's item property to:

 

 

First(Filter(entity, commonKey = opGal.Selected.commonKey, updated = 'updated (entity)'.No

 

 

The opGal gallery is looking at my main data table and filtering to a set of records. 'commonKey' is the column that holds a value common to certain records on the table, NOT in the opGal set. If a record in the opGal set with a commonKey is changed, all of the records with the same commonKey have to also change certain fields, but not all of them. So I have a Form1 to change the opGal.Selected, that's no problem. 

 

Form4's add image is set to default to opGal.Selected.image. I have a button to SubmitForm(Form1)  I'll paraphrase below:

 

SubmitForm(Form1);
If(opGal.Selected.common = Yes,
 SubmitForm(Form4))

 

 

Then Form4's OnSuccess property:

 

If(!IsBlank(First(Filter(entity, commonKey = opGal.Selected.commonKey, updated = 'updated (entity)'.No)),
SubmitForm(Form4);
Patch(entity, First(Filter(entity, commonKey = opGal.Selected.commonKey, updated = 'updated (entity)'.No),
{
updated = 'updated (entity)'.Yes
shortTextCDS: opGal.Selected.shortTextCDS,
longTextCDS: opGal.Selected.longTextCDS
}
);
Refresh(entity)

 

 

So that works, the "ForAll" is essentially handles by telling form the default to the first record of the records with same commonKey and updated = No, sends changes with the SubmitForm then changes the updated to Yes which kicks it of the filtered table and the next in line gets changed until that table is blank. I tried using Form4 to also change the updated column and the other columns that needed to be changed but it wasn't working well...it was finicky for some reason. The patch seemed to work better.

 

It seems to work fairly well though it is very work-aroundy. There's also a step tied into the Form1's submit button to reset the "updated" column back to "No" if it's to be a globaledit:

 

 

If(globalEdit,

ClearCollect(globEdit, ShowColumns(Filter(entity, commonKey = opGal.Selected.commonKey), "crd2e_stepkey"));


ForAll(RenameColumns(globEdit, "crd2e_stepkey", "patchKey"), 

Patch(entity, LookUp(entity, stepKey = patchKey),

{ 
        updated: 'updated (entity)'.No
} 
));

 

I suppose this could be done at the end of Form4's submit routine but I don't think it really matters. Anyway, this worked. It would be nice however if I could simply patch an new image to a record with an existing image. That would be amazingly simple and it's kind of mind boggling to me that it isn't possible in any straightforward way. 

View solution in original post

5 REPLIES 5
Highlighted
Helper V
Helper V

Re: Patch a CDS image column? Am I wasting my time?

Every time I try patching like this:

Patch(myEntity, myRecord,
{
imageColName: {Full: 'Image from different record', Value: 'Same image from different record'}
}
)


It lets me type it all in but as soon as I close the last parentheses it completely crashes the web editor and I have to start a new session. 

 

 

Highlighted
Helper V
Helper V

Re: Patch a CDS image column? Am I wasting my time?

This also crashed the web editor as soon as I typed the last parentheses:

 

Patch(Table(MyEntityRecord.imageCol), First(Table(MyEntityRecord.imageCol)),
{
Full: 'ImageFromDifferentRecord'.Full,
Value: 'ImageFromDifferentRecord
}
)

 

Highlighted
Community Support
Community Support

Re: Patch a CDS image column? Am I wasting my time?

Hi @enelson906 ,

Do you want to update the Image Type column of your CDS Entity using Patch function?

 

The user @JFN has faced same issue with you, please check my response within the following thread:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Can-t-get-image-to-save-to-custom-entity-in-...

 

Currently, I also have made a test on my side using Patch function, the Patch function could also update image type field in CDS Entity as well as the Edit form.

 

I have made a test on my side, please consider take a try with the following workaround:

5.JPG

 

6.JPG

Add a Gallery control in your app, connect it to your CDS Entity, then list the all available records within this Gallery.

Add a "Add Picture" control in your app, to pick up image for the selected item in your Gallery. Set the OnSelect property of the "Change" button to following:

Patch(
       TaskLists, 
       BrowseGallery1.Selected, 
       {
         TaskImage: {
                       Full: UploadedImage1.Image, 
                       Value: UploadedImage1.Image
         }
       }
)

Note: The TaskImage is a Image Type field in my CDS Entity (TaskLists). Please refer to the following GIF screenshot:

Test.gif

 

In addition, if you want to update the Image type field within a ForAll function, please take a try with the following formula:

ForAll(
       xxxxx,
       Patch(
             TaskLists, 
             "iterated record you want to update", 
            {
              ImageField: {
                          Full: UploadedImage1.Image, 
                          Value: UploadedImage1.Image
              }
            }
      )
)

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper V
Helper V

Re: Patch a CDS image column? Am I wasting my time?

Thank you for the response.  I actually came up with a work around that is similar to yours. I added an "updated" column to my CDS entity with default to "no". Then added a Form4 on a blank screen that won't be navigated to with just a picture and set it's item property to:

 

 

First(Filter(entity, commonKey = opGal.Selected.commonKey, updated = 'updated (entity)'.No

 

 

The opGal gallery is looking at my main data table and filtering to a set of records. 'commonKey' is the column that holds a value common to certain records on the table, NOT in the opGal set. If a record in the opGal set with a commonKey is changed, all of the records with the same commonKey have to also change certain fields, but not all of them. So I have a Form1 to change the opGal.Selected, that's no problem. 

 

Form4's add image is set to default to opGal.Selected.image. I have a button to SubmitForm(Form1)  I'll paraphrase below:

 

SubmitForm(Form1);
If(opGal.Selected.common = Yes,
 SubmitForm(Form4))

 

 

Then Form4's OnSuccess property:

 

If(!IsBlank(First(Filter(entity, commonKey = opGal.Selected.commonKey, updated = 'updated (entity)'.No)),
SubmitForm(Form4);
Patch(entity, First(Filter(entity, commonKey = opGal.Selected.commonKey, updated = 'updated (entity)'.No),
{
updated = 'updated (entity)'.Yes
shortTextCDS: opGal.Selected.shortTextCDS,
longTextCDS: opGal.Selected.longTextCDS
}
);
Refresh(entity)

 

 

So that works, the "ForAll" is essentially handles by telling form the default to the first record of the records with same commonKey and updated = No, sends changes with the SubmitForm then changes the updated to Yes which kicks it of the filtered table and the next in line gets changed until that table is blank. I tried using Form4 to also change the updated column and the other columns that needed to be changed but it wasn't working well...it was finicky for some reason. The patch seemed to work better.

 

It seems to work fairly well though it is very work-aroundy. There's also a step tied into the Form1's submit button to reset the "updated" column back to "No" if it's to be a globaledit:

 

 

If(globalEdit,

ClearCollect(globEdit, ShowColumns(Filter(entity, commonKey = opGal.Selected.commonKey), "crd2e_stepkey"));


ForAll(RenameColumns(globEdit, "crd2e_stepkey", "patchKey"), 

Patch(entity, LookUp(entity, stepKey = patchKey),

{ 
        updated: 'updated (entity)'.No
} 
));

 

I suppose this could be done at the end of Form4's submit routine but I don't think it really matters. Anyway, this worked. It would be nice however if I could simply patch an new image to a record with an existing image. That would be amazingly simple and it's kind of mind boggling to me that it isn't possible in any straightforward way. 

View solution in original post

Highlighted
Community Support
Community Support

Re: Patch a CDS image column? Am I wasting my time?

Hi @enelson906 ,

Have you solved your problem?

Is the solution I provided above helpful in your scenario?

 

I also agree with your solution almost. If you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,176)