Creating a seamless user experience in a SharePoint integrated Power App (Canvas App) can be challenging, especially when performing actions after form submission. Once a form is submitted, it closes, but the OnSuccess property allows you to run code post-submission.
In this blog, I’ll show you how to use the OnSuccess property to make changes to the newly created SharePoint item. Although you can’t use ThisItem or link directly to data cards, I’ll guide you through the process to ensure your app functions smoothly.
By the end, you’ll know how to enhance your Power App’s functionality and improve user experience. Let’s dive in!
Create a SharePoint list
- Create a SharePoint list on any SharePoint site.
- Add 1 text column named OnSuccesData.
Create the SharePoint integrated power app.
- Open the created SharePoint list.
- Click on Integrate, Power Apps, Customize Forms app.
- This will create a basic SharePoint integrated power.
- Remove the Attachments DataCard.
- Click on the SharePointForm1 and add a custom datacard.
- Add a label and a Text Input objects on the datacard.
- Rename the label to lbl_OnSuccesData.
- Rename the Text Input to txt_OnSuccesData.
- Set the OnChange to the following code.
- We need to store the Text value in a variable, because when you call directly for txt_OnSuccesData.Text it will work for editing items but not for creating items.
Set(varOnSuccesData, txt_OnSuccesData.Text);
- Set the 2 objects below each other.
- Set the text of the label to On Succes Data.
- Set the Default of the text input to “”.
- Create a new blank Power Automate flow from the power app.
- Name the flow to Actions after submission.
- Set the following text inputs.
- ItemID
- OnSuccesData
- Add the SharePoint action Update item and set it for the earlier created SharePoint list.
- Set the Id to ItemID from the power app.
- Set On Succes Data to OnSuccesData from the power app.
- Save the Power Automate flow.
- Open the Power App again.
- Select the OnSuccess property of the SharePointForm1 object.
- Add before the ResetForm(Self); code the following code to start the Power Automate flow.
Actionsaftersubmission.Run(SharePointForm1.LastSubmit.ID, varOnSuccesData);
- Test your app by putting a text in the title and a text in the second On Succes Data text input object.
- After you save the form, the flow will start and store the On Succes Data in the SharePoint on success data column.