cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NigelP
Level 8

Can I mix Patch and SubmitForm ?

Hi

 

I am using SharePoint Online with PowerApps.

 

I have an application that Gets the next submission number based on the value of the last ID of a list.

 

There have been a few situations when two submissions have the same submission number due to the fact that person "A" Creates a new Submission, but before they can submit the submission, person "B" also creates a submission and becuase person "A" has not submitted their submission, they get the same Submission number.

 

So to pevent this, when a person creates a new submission, I immediately create the record using Patch.  Then when the person submits their submission I use SubmitForm to submit the submission with all of the data in it.

 

I have two problems as result of using this method :-

 

1) When two people start the PowerApp at the same time to create a submission, I get two submissions with the same SUbmission number.

2) I sometimes get two records with the same submission number, one for the Patch and one for the subsequent SubmitForm.

 

a) is there a better way of doing this ?

b) How can I get an ID into a submit form so I dont get two submissions with the same Submission NUmber - becuase the SubmitForm thinks that this is a new Submission, rather than updating the current Submission created as a result of the PAtch command ?

 

Thanks

 

Nigel

2 REPLIES 2
Community Support Team
Community Support Team

Re: Can I mix Patch and SubmitForm ?

Hi @NigelP,

 

You could just leave it to the SubmitForm() function, and configure the Submission ID as a Server side data.

For SharePoint Online, when an item is created, there should be an ID created automatically, which I think should be helpful in your scenario.

Ad when suing the SubmitForm function, we could get the ID by EditForm1.LastSubmit.Id attribute.

 

Using Patch() function before the SubmitForm function should work, basically we need to make some changes for the Form control:

1. Siwtch the Form Mode to Edit after the Patch function, 

2. Switch the Item property to the record created by the Patch() function,

 

The formula for the button of the patch should be:

ClearCollect(NewRecord, Patch(Source, Defaults(Source), {MissionID:NewId}));EditForm(Formcontrol)

Then under the EditForm control item property, enter the following:

If(!IsEmpty(NewRecord),first(NewRecord),Gallery.Selected)

After the configuration above, under the OnVisible property of the first screen, enter the following:

Clear(NewRecord)

Let me know if this works.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NigelP
Level 8

Re: Can I mix Patch and SubmitForm ?

Hi Michael

 

I tried this and I had some problems.

 

The line If(!IsEmpty(NewRecord),first(NewRecord),Gallery.Selected) kept resolving to Gallery.Selected so picked up a ramd item out of the Gallery.

 

A way I tried was using a global Variable :rather than a collection and replacing the ClearCollect with a Set. and the Clear with Set(NewRecord,"");

 

Which seemed to work better.

 

 

The problem is that the user can save the record and then edit again, they can create a new record and they can select a record and edit it.

 

SO getting the above to work with all conditions is proving a problem.as the user can either edit a newly created record or can select a record from the gallery.

 

Regards

 

Nigel

I

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 156 members 5,339 guests
Please welcome our newest community members: