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

Refresh Form

Hello,

 

I have a form which the user fills out and then a button which patches the info to a sharepoint list.

 

In sharepoint when a new item is created it is given a unique 'ID'. I want to pull this back to into the form so that after the first submit, the ID is on the form. Currently, it will only populate if i navigate away and then back again. Resetform or newform dont work as the default item is the gallery selection which of course wont be a newly created item.

 

I want to use a patch and not a submit form as not all fields should send data on first submit.

 

Any ideas?

 

Thanks in advance 🙂

3 REPLIES 3
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Refresh Form

After the submission of a new item via SubmitForm, you can access the ID property for the SharePoint in the OnSuccess action of the form, via the LastSubmit property. You would have something along the lines of this expression in the OnSuccess property (assuming the form control name is 'EditForm1'):

If(
    EditForm1.Mode = FormMode.New,
    Set(NewId, EditForm1.LastSubmit.ID))

At this point you should be able to reference the variable 'NewId' in your app.

Max1
Level 8

Re: Refresh Form

Thank you for your reply.

 

Just to confirm, that the last submit and onsuccess functions work even when you are not submitting a form, merely patching the source?

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Refresh Form

Ah, got it. If you are using Patch, then you can use the return value of that function to retrieve the id of the newly inserted item. For example, this code would set the NewId variable from the result of the Patch:

UpdateContext({
    PatchResult: Patch(
        <DataSourceName>
        Defaults(<DataSourceName>),
        {
            Field1: Value1,
            Field2: Value2
        })});
If(
    Not(IsBlank(PatchResult)),
    Set(NewId, PatchResult.Id))

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,249)