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

How to use table with 1 record as record in Patch function

Hi Folks,

 

My below filter results in a table with 1 record only, but i want to use it in Patch function:

 

Patch(ProjectDataAccessControl , Filter(ProjectDataAccessControl, User().FullName in ProjectDataAccessControl.User), {ColumnA: Text})

 

How do I convert/use this table into/as record?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @IMathur ,

 

The delegation issue is seemly caused by in operators and User() function in Filter formula, and the First(Filter(..))  function can be replaced by LookUp function which can find the first record of all records that meet the criteria. 

 

Please try to save the User().FullName to variable at the start of app.

Set(VarUserName, User().FullName)

Then modify the Patch formula as follows.

Patch(ProjectDataAccessControl , LookUp(ProjectDataAccessControl, User = VarUserName ), {ColumnA: Text})

Hope this helps.

Sik

View solution in original post

5 REPLIES 5
IMathur
Helper V
Helper V

 used First(Filter(ProjectDataAccessControl, User().FullName in ProjectDataAccessControl.User)), but seems like First is not delegable function, which function should i use here?

 

GarethPrisk
Resident Rockstar
Resident Rockstar

Presumably, the Patch function is added to the onSelect property of some control. It's almost always a best a practice to use a context variable to build your object before passing it to a Patch. In your case, put a function before the Patch function that sets a context variable. Like:

UpdateContext( { locName: (Your Patch Record) } );

 

Then put the context variable in your Patch. This allows you to trace what was being patched, and can help with delegation issues and troubleshooting.

Hi @GarethPrisk , should i put this Update Context in Onselect property only?

 

Anywhere that would change the context of the record you're going to patch. You may need to reset it after a patch, for example. You may update its value based on user input from different controls, for example.

 

Context variables only exist on a screen, so if you need it on multiple, consider a global variable, by the way.

Hi @IMathur ,

 

The delegation issue is seemly caused by in operators and User() function in Filter formula, and the First(Filter(..))  function can be replaced by LookUp function which can find the first record of all records that meet the criteria. 

 

Please try to save the User().FullName to variable at the start of app.

Set(VarUserName, User().FullName)

Then modify the Patch formula as follows.

Patch(ProjectDataAccessControl , LookUp(ProjectDataAccessControl, User = VarUserName ), {ColumnA: Text})

Hope this helps.

Sik

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,790)