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

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch function does no...
Power Apps
Unanswered

Patch function does not work at the beginning when the app is loading

(0) ShareShare
ReportReport
Posted on by 155

Hi,

 

My issue here is when I open the app, immediately do a update and submit which include a patch function, it did not work, I am guessing there are something still be loading in background. It will be worked if I just wait one or two minutes, does anyone get similar issue and any ideas? I l already enabled Delayed load feature.

 

Regards

Steven

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at
    Re: Patch function does not work at the beginning when the app is loading

    @StevenZhang 
    Please share your code.  It is impossible to know what is going on without it... I assume you put the code in the OnStart property of the app.

  • StevenZhang Profile Picture
    155 on at
    Re: Patch function does not work at the beginning when the app is loading

    @mdevaney  here is the code,

    UpdateContext({showbackarrow_in_updatestatus:false});
    UpdateContext({myprogressvalue:Value(DataCardValue86.Text)});
    UpdateContext({myKRstatus:DataCardValue1.Selected.Value});
    Patch('Individual OKR',First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),{ProgressValue:myprogressvalue});
    Patch('Individual OKR',First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),{Status_OKR:myKRstatus});

    //Patch('Individual OKR',First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),{ProgressValue:Value(DataCardValue86.Text)});
    //Patch('Individual OKR',First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),{Status_OKR:DataCardValue1.Selected.Value});

    Patch('Individual Objective',First(Filter('Individual Objective',ID = MyselectedObj.ID))
    ,{Completion_MyObj:CompletionofMyObjective.Text});
    SubmitForm(AddStatusofMyKRForm)

  • Verified answer
    mdevaney Profile Picture
    29,989 Moderator on at
    Re: Patch function does not work at the beginning when the app is loading

    @StevenZhang 
    I have re-oraganized your code making it easier to read.  Also, I removed the PATCH functions that were commented out.

    UpdateContext({showbackarrow_in_updatestatus: false});
    UpdateContext({myprogressvalue: Value(DataCardValue86.Text)});
    UpdateContext({myKRstatus: DataCardValue1.Selected.Value});
    
    Patch(
     'Individual OKR',
     First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),
     {ProgressValue:myprogressvalue}
    );
    
    Patch(
     'Individual OKR',
     First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),
     {Status_OKR:myKRstatus}
    );
    
    Patch(
     'Individual Objective',
     First(Filter('Individual Objective',ID = MyselectedObj.ID)), 
     {Completion_MyObj:CompletionofMyObjective.Text}
    );
    
    SubmitForm(AddStatusofMyKRForm)

     

    I would like you to replace your code with this instead.  I've made a few improvements.  FIRST + FILTER is very slow.  Instead you can simply use the LOOKUP function.  I've also put a CONCURRENT function in there to run all the PATCH functions simultaneously.

     

    // store values in variables
    UpdateContext({showbackarrow_in_updatestatus: false});
    UpdateContext({myprogressvalue: Value(DataCardValue86.Text)});
    UpdateContext({myKRstatus: DataCardValue1.Selected.Value});
    
    // patch datasource
    Concurrent(
     Patch(
     'Individual OKR',
     LookUp('Individual OKR', ID = GalleryKR.Selected.ID),
     {ProgressValue:myprogressvalue, Status_OKR:myKRstatus}
     ),
     Patch(
     'Individual Objective',
     LookUp('Individual Objective',ID = MyselectedObj.ID), 
     {Completion_MyObj: CompletionofMyObjective.Text}
     )
    )

     

    Lets test the PATCH functions first and see if they work.  Do not include the SUBMITFORM function for now.  We want to isolate what we are testing.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • StevenZhang Profile Picture
    155 on at
    Re: Patch function does not work at the beginning when the app is loading

    @mdevaney  thank you very much for that, let me try them. 

     

    Regards

    Steven

  • StevenZhang Profile Picture
    155 on at
    Re: Patch function does not work at the beginning when the app is loading

    @mdevaney  I just did testing, the speed is much better. but still having same issue that just happened at the beginning of first time to open the app. not user if I describe it clear. 

    the step is,

    1. open a browser.

    2. open the app.

    3. immediately to enter data and submit once the form appears.

     

    Regards

    Steven

  • Verified answer
    StevenZhang Profile Picture
    155 on at
    Re: Patch function does not work at the beginning when the app is loading

    I tried to disabled Preview features "Delayed load", and it works. not sure if it is the root cause.

  • Verified answer
    v-xida-msft Profile Picture
    on at
    Re: Patch function does not work at the beginning when the app is loading

    Hi @StevenZhang ,

    Have you solved your problem?

     

    Yeah, you are right. The "Deplay load" option would affect the execution speed sometimes in a canvas app. Also please consider turn off the "Use non-blocking OnStart rule" option within Advanced settings of your App settings of your app, then re-publish your canvas app, check if the issue is fixed.

     

    If you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

     

    Regards,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 757 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard