cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tricky778
Helper II
Helper II

Submit form and patch intermittent

I have a PowerApp using a SharePoint list for it's data repository. The SharePoint list it is connecting to is called LeaseData.

I have adjusted the 4 dropdowns below to create cascading dropdowns within the form by pulling data from another list (LegalEntity) in the same SharePoint site:

 

LEGALENTITY:    Sort(Distinct(LegalEntity, Legal_Entity_Code),Result)

PLANT:               Distinct(Filter(Plants, 'Legal Entity Code' = DropdownLegalEntity.Selected.Result), Plant)

AXCODE:            Filter(Plants, Plant = DropdownPlant.Selected.Result)

HFMCODE:         Filter(Plants, Plant = DropdownPlant.Selected.Result)

 

It works beautifully in the form in that if you select a certain Legal Entity it the Plant dropdown automatically filters to show only plants for that Legal Entity and so forth. 

 

On the submit button for the form I need to patch those values back to the original SharePoint list (LeaseData). The syntax I'm using is to submit the form then patch those records:

 

SubmitForm(Form1);
Patch(LeaseData,Form1.LastSubmit,{LEGALENTITY:DropdownLegalEntity.SelectedText});
Patch(LeaseData,Form1.LastSubmit,{PLANT:DropdownPlant.SelectedText});
Patch(LeaseData,Form1.LastSubmit,{AXCODE:DropdownAXCode.SelectedText});
Patch(LeaseData,Form1.LastSubmit,{HFMCODE:DropDownHFMCode.SelectedText})

 

However it works intermittently, i.e. one test will patch all 4 fields as required, another test will patch only 1, none, 2 etc. 

 

It suspected a timing issue in that the form hadn't fully submitted so the patch didn't update (or did and got wiped out by the form). I tested by just using the submitform syntax, and then ran a separate button 10 seconds later to run the patch (that worked fine). 

 

Is there something I can add to the below syntax to delay before the patch attempts? 

 

SubmitForm(Form1);
Patch(LeaseData,Form1.LastSubmit,{LEGALENTITY:DropdownLegalEntity.SelectedText});
Patch(LeaseData,Form1.LastSubmit,{PLANT:DropdownPlant.SelectedText});
Patch(LeaseData,Form1.LastSubmit,{AXCODE:DropdownAXCode.SelectedText});
Patch(LeaseData,Form1.LastSubmit,{HFMCODE:DropDownHFMCode.SelectedText})

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Tricky778 

As @Drrickryp mentioned, anything you want to occur after your SubmitForm should be done in the OnSuccess of the form and never directly after your SubmitForm function in your formula.

 

However, it also appears that you are trying to patch the same record that you just submitted.  This can all be avoided (hitting the datasource 4 more times) by just submitting those values with the form.  If you don't want those fields to be visible in the form, just set the visible to false.  Then all of the fields will be submitted at once.

Also, if those dropdowns are in your form in anyway, you should avoid referencing them after the submit as their state and value might not be what you expect.  One more good reason to incorporate all of those into your form and the submit.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
diegoadum
Advocate V
Advocate V

Hi there!! Maybe this is a very silly suggestion but, if as you said this is a matter of timing, why don't you try to add a couple of lines to count something in order to create a sort of pause effect? Another suggestion could be to try using Selectd.Value for the Dropdown instead.

Drrickryp
Super User
Super User

@Tricky778 

You should almost never chain commands with the SubmitForm() function.  Instead put them in the OnSuccess property of the form.  You don't want them to execute until the form is successfully submitted. 

RandyHayes
Super User
Super User

@Tricky778 

As @Drrickryp mentioned, anything you want to occur after your SubmitForm should be done in the OnSuccess of the form and never directly after your SubmitForm function in your formula.

 

However, it also appears that you are trying to patch the same record that you just submitted.  This can all be avoided (hitting the datasource 4 more times) by just submitting those values with the form.  If you don't want those fields to be visible in the form, just set the visible to false.  Then all of the fields will be submitted at once.

Also, if those dropdowns are in your form in anyway, you should avoid referencing them after the submit as their state and value might not be what you expect.  One more good reason to incorporate all of those into your form and the submit.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Tricky778
Helper II
Helper II

Thanks guys, my choice cards weren't submitting as the update value of of my choice field had dropdownname.selected rather than just dropdownname, adjusted and they updated fine. Thanks for the pointers

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,201)