web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

Patch Help

(0) ShareShare
ReportReport
Posted on by

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"})

Categories:
I have the same question (0)
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

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

  • BenGillard Profile Picture
    on at
    Trying to update the record that is being created with the Onstart property.
    Thanks
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    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"})

     

     

  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    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,

  • BenGillard Profile Picture
    on at
    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard