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 Platform Community / Forums / Power Apps / Issue with Patch and N...
Power Apps
Answered

Issue with Patch and Navigate

(0) ShareShare
ReportReport
Posted on by 49

In my App I have a Gallery to replicate a "Repeating Table"..

It works like a charm, in that the Approver Submit Button updates the secondary list correctly.

It then navigates, briefly, to the "Success Screen" ..This is where it gets weird..
After a second or two, it navigates back to the EditForm which has the last Approver data in it.

Patch for the Button:
Clear(Apprcollection);

If( !IsBlank(ListItemID), ForAll(Apprcollection, If( !IsBlank( ApprovedValSel), Patch(CABApproval, Defaults(CABApproval), {ApprName: CurrentUserName, ApprComments: CommentTxt, ApprVal: ApprovedValSel, ApprDate: ApprovedDate, ApprEmail: CurrentUserEmail, MasterID: ListItemID}))));
Navigate(SuccessScreen, ScreenTransition.Fade)

 

My SuccessScreen is very basic -  a Label and a button that takes them back to the SP list.
Nothing in the "OnVisible" ..

Thoughts?

Categories:
  • MF-11091236-0 Profile Picture
    41 on at

    When navigating back to the original form  reset it and set the original form display mode to new.

    ResetForm({form_name}); NewForm({form_name})

     

    I would recommend a looking at a component to display a pop-up message verse another screen.

  • shanemeisnerdhg Profile Picture
    49 on at

    @Slevin3900 - Thanks, but I don't want them to be redirected to the form at all.

    Once a Approver Submits Approval, I want them taken to the Success Screen and Stop..
    This works for Normal "Submit Button" when users enter a new request without issues.

    But right now, after an Approver clicks the Button to patch the data, it brings them to the success screen for a second or two and then they are redirected back to the form which I can't figure out the why..

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @shanemeisnerdhg ,

    I will firstly ask a question and make a suggestion on doing your Patch a lot more efficiently - the question is in comments at the top of the code and if you Patch the table after creating it, rather than looping through it, you will find it runs much faster.

    Clear(Apprcollection); //how can you clear this and then patch the contents?
    If(
     !IsBlank(ListItemID),
     Patch(
     CABApproval, 
     ForAll(
     Filter(
     Apprcollection, 
     !IsBlank(ApprovedValSel)
     ),
     {
     ApprName: CurrentUserName, 
     ApprComments: CommentTxt, 
     ApprVal: ApprovedValSel, 
     ApprDate: ApprovedDate, 
     ApprEmail: CurrentUserEmail, 
     MasterID: ListItemID
     }
     )
     )
    );
    Navigate(
     SuccessScreen, 
     ScreenTransition.Fade
    )

    However, that is not your immediate problem. There is nothing in what you have posted that would explain the behaviour you are experiencing, so (obviously) it is something you have not considered. You are not submitting a Form, so we can eliminate OnSuccess, so firstly have you looked at the OnVisible of the Success screen? Also where is the button you are running this code from (in a Form, on the screen, in a gallery)?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • shanemeisnerdhg Profile Picture
    49 on at

    @WarrenBelz - Thanks for your response!

     I did try commenting out the Clear collection, which made things worse as it copied the last Approver info. I'll expand more on the App.

    This Patch is running from inside a Gallery.

    When an Approver( could be up to 8 depending on the type of Change Request) opens the submitted item, they click the "Add Approver" button to build an Empty" collection: Collect(Apprcollection, {ApproverName: "", CommentTxt: "", ApprovedValSel: "", ApproverEmail: "", ApprDate: "" , ShowSaveButtons: true , ShowAppr: true}))

    This then presents them a yes/no dropdown, a comment field, and the Submit Approval button:

    shanemeisnerdhg_0-1650458333556.png

    So as to make it easier for the Approvers, I Patch their response to my Secondary list and then Navigate to the success screen. At this point, for whatever reason, it gets to the Success screen for a second or two, then refreshes the browser window, showing the Approvers entry.

     

    Note - This Success screen is also used for "Normal" submit of the form without any issues.

    It's almost like the Patch is responding to the App after success and then refreshing the browser window.

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @shanemeisnerdhg ,

    One thing to look for is that when you initiate a function (such as your Patch) from inside a gallery, it resets, meaning that any OnChange events on controls in the gallery will trigger. You might have a look there.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • shanemeisnerdhg Profile Picture
    49 on at

    @WarrenBelz Thanks for the response.. Inside the gallery there is only 1 field that has a OnChange setting.

    When user selects Yes or No for Approved, the OnChange is set as this:

    Set(AprCurUserName,CurrentUserName); UpdateContext({ApproverDate: Now()}) ; Set( NeedsSaved, true) //Set username and Approver date( to now) and force user to save.

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @shanemeisnerdhg ,

    There is nothing there that Navigates (as you would realise). Have you run a monitor session to see what is triggering this?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • Verified answer
    PaulD1 Profile Picture
    2,914 on at

    Two thoughts.

    1. Do you have any timer controls? Could they be responsible for the navigation?

    2. You say >> then refreshes the browser window<< Can you give more info on this? Is this PowerApps 'crashing' and then reopening?  I've only had this in one App and the only fix was to turn on the experimental setting 'Keep recently visited screens in memory'. In that case, the bug was related to a Power Apps bug in re-rendering combo boxes as screens were closed/opened (loaded in and out of memory) - the browser screen would go blank, a spinning loading graphic appeared and then the Power App restarted. Turning on the setting reduced the number of times the screen had to be loaded into memory which seemed to fix the issue.

  • shanemeisnerdhg Profile Picture
    49 on at

    @PaulD1 Thank you!! No idea how/why..

    but turning that on from the preview settings did the trick!!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard