cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenGillard
Helper III
Helper III

Patch Help

Trying to patch the onstart record when the user navigates to another screen. Onstart works fine but the Patch is not. Any help would be great.

 

On Start:

Collect(DWAnalytics,{UserName:Office365Users.MyProfile().DisplayName,UserEmail:Office365Users.MyProfile().Mail,LoginDate:Today(),LoginTime:Text( Now(),"[$-en-GB]hh:mm:ss"),UniqueID2:Office365Users.MyProfile().Mail&Text(Now(),"[$-en-GB]hhmmss")});

Set(UniqueValue,Office365Users.MyProfile().Mail&Text(Now(),"[$-en-GB]hhmmss"))


Text Label (UniqueID): Text Property is UniqueValue


Another Screen, On Visible:

Patch(DWAnalytics,{UniqueID2:UniqueID.Text},{Office365Screen:"Y"})

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @BenGillard ,

The right syntax of Patch should be:

Patch( DataSource, BaseRecord, ChangeRecord)

 

If you want to create a new record, use Defaults(DataSource) to represent BaseRecord.

If you want to update an existing record, you should list the record that you want to update to represtent BaseRecord.

Usually, we use LookUp function to filter the record that you want to update.

 

For example:

Patch(DWAnalytics,LookUp(DWAnalytics,UniqueID2=UniqueID.Text),{Office365Screen:"Y"})

 

Here's a doc about this function for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

 

 

Best regards,

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

View solution in original post

5 REPLIES 5
Jeff_Thorpe
Super User
Super User

Are you trying to add or update a record with the Patch()? 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Trying to update the record that is being created with the Onstart property.
Thanks

Ok, if I understand this there is a collection created when the app starts with one record and you would like to update that record. The issue I see is that Office365Screen doesn't exist when the collection is created.

 

I would recommend adding Office365Screen:"N" to the record when it is created in the OnStart

 

Then you should be able to use this Patch() to update the record:

 

Patch(DWAnalytics, First(DWAnalytics), {UniqueID2:UniqueID.Text , Office365Screen:"Y"})

 

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
v-yutliu-msft
Community Support
Community Support

Hi @BenGillard ,

The right syntax of Patch should be:

Patch( DataSource, BaseRecord, ChangeRecord)

 

If you want to create a new record, use Defaults(DataSource) to represent BaseRecord.

If you want to update an existing record, you should list the record that you want to update to represtent BaseRecord.

Usually, we use LookUp function to filter the record that you want to update.

 

For example:

Patch(DWAnalytics,LookUp(DWAnalytics,UniqueID2=UniqueID.Text),{Office365Screen:"Y"})

 

Here's a doc about this function for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BenGillard
Helper III
Helper III

Thanks for the reply.
I have added N to the on start option.
Is there a way to patch without using the first call as I believe this will cause delegation issues?
The data set is already close to 2000 records and growing daily. Thanks

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,186)