cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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

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.

Anonymous
Not applicable

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?

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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,389)