cancel
Showing results for 
Search instead for 
Did you mean: 

SharePoint Integration: Remove redirect to first list item after a new item has been created

When a new SharePoint item is created via integrated Power Apps and the OnSuccess actions of the form (ResetForm and RequestHide) are disabled (or postponed to be called after some other action), after click on the save button, the first list item instead of the new created one is shown.

 

Sample use case:

Show a success message or send an email including values of the new item from inside the Power App. (Sending an email via Power Automate Flow is not always an option, for example if a user should be able to customize the message.)

 

Steps to reproduce:

  1. Create a new SharePoint list.
  2. Create a new item.
  3. Create a new Power App to replace the default SharePoint form (Integrate -> Power Apps -> Customize forms)
  4. In Power Apps studio remove or comment out the OnSuccess actions of the form (ResetForm and RequestHide)
  5. To be able to see if the default form has been replaced, I suggest changing something in the form (add an element or change an existing one).
  6. Save and publish the new form.
  7. Wait until the default form has been replaced (click the new button of the list and reload the site until you see the customized form).
  8. Create a new list item having a different title as the existing one.
  9. Click on save.

 

Expected behavior: 

The Power Apps Form shows the new created item.

 

Current behavior:

Another item is shown.

 

Additional Information:

In generated Power Apps, there is a function SharePointForm1.Item that looks like it should load the first item if SharePointIntegration.Selected is not set.

If(IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),First(<MyListName>),SharePointIntegration.Selected),

Changing First(<MyListName>) to Last(<MyListName>) has no effect. I assume SharePointIntegration.Selected is already set to the first item by SharePoint.

 

Possible Workaround:

Save the ID of the new created item in SharePointIntegration.OnSave

SubmitForm(SharePointForm1);
Set(myId,SharePointForm1.LastSubmit.ID)

and use it to load the new item in SharePointForm1.Item

If(IsEmpty(myId),

If(IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),First(<MyListName>),SharePointIntegration.Selected),

LookUp(<MyListName>,ID = myId))

Status: New