How to Get and Delete a SharePoint list view using Power Automate?

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 and Delete the SharePoint list view using Microsoft Power Automate

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.
power automate get sharepoint list view
  • Then provide the flow name, and select the Manually to trigger a flow. Then click on Create.
power automate get list views
  • Now you can see Manually trigger flow is added to the flow page.
Using Microsoft Power automate get sharepoint list view

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’.

power automate get list views
  • 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
how to get list views using power automate

Now run the flow manually you can see in the output of the rest API action, it holds all the SharePoint list views.

how to get  SharePoint list views using power automate

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']}')
power automate get list views

Now run the flow manually and provide the user input as Due Date Filter.

Get a particular SharePoint list view using Power Automate

You can see the view ‘Due Date Filter’ view is fetched.

Get a particular SharePoint list view using Power Automate

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']}
Microsoft power automate get list views

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
Delete SharePoint list view using Power Automate

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:

>