Hello Friends,
Welcome back with another post on Power Automate. In last 2 posts, we were discussing about CRUD operations using REST API in Power Automate with PowerApps. There, we had learnt about Insert and Update the data in SharePoint. You may visit my these posts by clicking on below link-
- Power Automate: CRUD Operations Using REST API - Part 1
- Power Automate: CRUD Operations Using REST API - Part 2
In this post, we will learn Delete the data. For this, we have to do nothing very much. Let's start without any wait-
- Open the Power Automate portal and make a copy of the Power Automate flow, we had created in last post by clicking on "My flows". Then click on 3 dots showing ahead of flow "HTTPCRUD-Update" and choose "Save As". It will ask you to provide the name of flow you want to make as a copy. give the name "HTTPCRUD-Delete" and click on Save.
- It will create a copy of the flow and by default retain it in Turn off mode. Click on 3 dots ahead of this flow and choose Turn on.
- Again click on 3 dots and click on Edit.
- As we have to delete the record, that means, we only need the ItemID of that record. So we can delete the Compose actions written for Title and PinCode. After deleting, we will have only one input parameter "ComposeItemID_Inputs"
- Now expand the step "Send an HTTP request to SharePoint".
- Change the Method from PATCH to DELETE.
- Add below key-value pair in Headers section-
- Enter key: X-HTTP-Method
- Enter value: DELETE
- Delete the contents of Body section as we have not to update anything; we are deleting the item.
- That's all in Power Automate. Click on Save button to Save the flow.
- Now come back to PowerApps. Open the PowerApps, we have updated in last post and click on EditScreen1.
- Add one more button just next to Update and rename it's text as "Delete" and rename this button as btnDelete.
- Now click on the formula box of OnSelect property for this btnDelete and remove the existing code. Then click on Action >> Power Automate and choose "HTTPCRUD-Delete".
- As you can see the tooltip, you will be getting only 1 input parameter-
- ComposeItemID_Inputs
- Provide the value of ID for the item you want to delete and complete the formula.
- the complete code will be-
'HTTPCRUD-Delete'.Run(BrowseGallery1.Selected.ID); Navigate( BrowseScreen1, None );
- That's all. Save the PowerApps and run to see the magic.
- For the easiness and clarity, I had added one more record in list. Let's try to delete it.
- And the SharePoint list after deleting the data is-
- With this, Part 3 of the series is over. We have learned delete record using PowerApps, Power Automate and REST API.
- One line, I would like to add here is, I had added custom buttons to perform the actions. The same code can be written on the icons provided for Add/Update/Delete the item in PowerApps.
- So far, we have learnt abut the Insert, Update & Delete the record.
- The next two parts of this series are quite important as in that posts we will learn on how to get the data using Power Automate, REST API and PowerApps.
- Stay tuned...
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.
Stay Safe !
Stay Healthy !
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.