In this Power Automate tutorial, I will show you, how to get SharePoint list views using Power Automate. I will then show, how to delete a SharePoint list view using Power Automate.
For example, we will see:
- How to get all list views from a SharePoint list using Power Automate
- How to get a particular view from a SharePoint list using Power Automate
- Delete list view from SharePoint list using Power Automate
We will use the below list view ‘Due Date Filter to perform these operations in the SharePoint list called Project Task. Whereas the default view is the ‘Due Date Filter’ view which is a prebuilt view in every SharePoint list.
Get all SharePoint list views using Power Automate
Here we will see how to get all SharePoint list views using Power Automate rest API.
For this, we will create an Instant cloud flow, and then we will do the rest API call to get all the List view.
- Login to Power Automate, click on +Create -> then select Instant Cloud Flow.
- Then provide the flow name, and select the Manually to trigger a flow. Then click on Create.
- Now you can see Manually trigger flow is added to the flow page.
Next, we will add a User Input Text field, that will take the view name, so expand the action. Click on Add an Input -> select Text -> provide the field name as ‘View name’.
- Now click on the +New step -> select ‘Send an HTTP request to SharePoint’ action. Then provide the below information:
- Site address: Select or provide the SharePoint site address.
- Method: Select the Method as Get, as we are fetching all the views from the SharePoint list.
- Uri: Provide the below API to do the rest API call
_api/web/lists/getByTitle('Project%20Task')/views
Now run the flow manually you can see in the output of the rest API action, it holds all the SharePoint list views.
This is how to get all SharePoint list views using Power Automate.
Get a particular SharePoint list view using Power Automate
Here we will see how to get a particular view from a SharePoint list using Power Automate.
For this, we will use the below rest API call that will get the Particular list view from the SharePoint list using Power Automate.
So create a Manually trigger flow like the above, and then select Send an HTTP request to SharePoint action. Then provide the below information:
- Site address: Select or provide the SharePoint site address.
- Method: Select the Method as Get, as we are fetching all the views from the SharePoint list.
- Uri: Provide the below API to do the rest API call
_api/web/lists/getByTitle('Project%20Task')/views/getbytitle('@{triggerBody()['text']}')
Now run the flow manually and provide the user input as Due Date Filter.
You can see the view ‘Due Date Filter’ view is fetched.
This is how to get a particular SharePoint list view using Power Automate.
Delete SharePoint list view using Power Automate
Here we will see how to delete the list view from the SharePoint list using Power Automate.
To delete the list view ‘ Due Date Filter’, after the above action i.e ‘Get all the list views from SharePoint list’. Just click on the +New step -> select Apply to each action.
Then provide the below information, to get the Title of the View:
- Select an output from previous steps: Provide the below expression:
@{body('Send_an_HTTP_request_to_SharePoint')['d']['results']}
Next, click on the Add an action -> select Compose action, then provide the below information:
- Inputs: Provide the below expression:
@{items('Apply_to_each')?['Title']}
After that click on Add an action -> select Condition control action, then provide the below information
- Choose a value: Select the composed output from dynamic content.
- Operator: Select the operator as ‘is equal to’
- Choose a value: Write the value as View name from dynamic content
If the condition is true, then click on Add an action, and select the ‘Send an HTTP request to SharePoint’ action. Then provide the below information.
- Site address: Select or Provide the SharePoint site address.
- Method: Select the Method as POST to delete the list view.
- Uri: Provide the URI as below code
_api/web/lists/getByTitle('Project%20Task')/views/getbytitle('@{outputs('Compose')}')/deleteObject
Now if we will run the flow, you can see in the Due Date Filter view is deleted from the SharePoint list.
This is how to delete a SharePoint list view using Power Automate.
Conclusion
In this Power Automate tutorial, we saw how to get all list views from a SharePoint list using Power Automate. Also, we saw how to delete a SharePoint list view using Power Automate.
You may like the following tutorials:
- How to replace text in a Word document in Power Automate?
- Power Automate delete emails older than
- How to Apply Filter Between Dates in Power Automate?
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com