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 / Sharepoint Patch not w...
Power Apps
Answered

Sharepoint Patch not working in OnSelect. It was working for a couple weeks then stopped. Sometimes when clicking, it will delete data in a different column.

(0) ShareShare
ReportReport
Posted on by 12

This has been driving me crazy. I had this issue several weeks ago, and fixed it by recreating the button and pasting the code back in, but now it is starting again. 

 

Sometimes the code will actually remove the 'Approved' status from the MgrApprovalStatus column for the same record in Sharepoint. 

 

OnSelect actions:

 

Set(
varITApproval,
"Approved"
);
Patch(
ITOnboardingForm,
LookUp(
ITOnboardingForm,
ID = ThisItem.ID
),
{ITApprovalStatus: varITApproval}
);
SubmitForm(ITForm);
Refresh(ITOnboardingForm);
Navigate(BrowseScreen1);

 

The initial screen is using a gallery, and there is a lot of code in the "Next Arrow", not sure if that is where the issue lies:

 

Refresh(ITOnboardingForm);
Select(Parent);

Set(
varRecord,
ThisItem
);
Set(
formType,
"Edit"
);
Set(
selectedItem,
ThisItem
);

If(
selectedItem.HRApprovalStatus = "Draft",
EditForm(NewUserForm);
Set(
varTitle,
selectedItem.Title
);
Set(
varHRStatus,
selectedItem.HRApprovalStatus
);
Set(
varSupervisor,
selectedItem.Supervisor
);
Navigate(
NewUserForm,
ScreenTransition.None
),
selectedItem.ITApprovalStatus = "Approved",
Navigate(Review),
selectedItem.MgrApprovalStatus = "Approved",
EditForm(ITForm);
Set(
varITApproval,
selectedItem.ITApprovalStatus
);
Set(
varSupervisor,
selectedItem.Supervisor
);
Navigate(IT_Approval),
selectedItem.HRApprovalStatus = "Approved",
EditForm(MgrForm);
Set(
varMGRApproval,
selectedItem.MgrApprovalStatus
);
Set(
varSupervisor,
selectedItem.Supervisor
);
Navigate('MGR Approval'),
Navigate(Review)
)

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jeremywilles 

    Is the record in the ITForm the same one you are trying to patch?  If so, this should all be done in the form and not separately as you can collide the record results.

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @jeremywilles 

    It is usually a mistake to chain more than a SubmitForm() in the button that actually submits the form.  The Navigate() functions should be in the OnSuccess property of the form itself since you do not wish to execute them unless the form is successfully submitted.  I have no idea what you are doing with the Patch() in the OnSubmit button.  If possible, include all of the fields that you need to update in your form and avoid doing an extraneous patch. A well constructed form should do everything you need in the SubmitForm() function/operation.

    In addition, I don't understand why you need to create all of the global variables when you can just refer back to the fields in the gallery directly for the defaults in your form. (Ie. Gallery1.Selected.Supervisor, Gallery1.Selected.Title, etc.).  It seems unnecessarily complicated to me but maybe I don't understand what you are doing.

  • jeremywilles Profile Picture
    12 on at

    I'm not sure what I'm doing either, was asked to update an already existing app.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @jeremywilles 

    Putting me on.gif

     

  • jeremywilles Profile Picture
    12 on at

    The button also acts as the manager "Approving" the form, which also launches a Power Automate flow. 

  • jeremywilles Profile Picture
    12 on at

    Unfortunately no. 

     

    New to Power Apps, was asked to get this one working. The button submits the form AND marks that record as 'Approved' what is the best practice to update the status of a field via a button?

  • jeremywilles Profile Picture
    12 on at

    Moved the 'Submitform()' to the top of the OnSelect. Then put the Patch(). 

    Moved the Navigate() to the OnSuccess. 

    Field successfully updating now. 

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jeremywilles 

    All good, but your Patch should really be in the OnSuccess as well - you would not want to patch if there was a failure.  This is the purpose of the OnSuccess and OnFailure on the forms - so that you can do things when either condition happens.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard