web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Using Flow to change f...
Power Automate
Unanswered

Using Flow to change filters in a SharePoint List View

(0) ShareShare
ReportReport
Posted on by

Hello All, 

I was wondering if any of you can help me.

I'd like to build a flow that when an item in a SharePoint list is created that the flow changes the filters of a specific view in the list. Is this possible and how would I go about building this flow in power automate?

Any thoughts gratefully received.

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Deb_B_Dev,

     

    You can use the ViewQuery property in a REST API call for this. You can update the property in a Send an HTTP request to SharePoint action.


    Below is an example of that approach.

     

    Let's say you have the list below with the All Items view and you want to sort your list items on DueDate Older to newer (ascending). In addition to that you also want to exclude items where the PercentComplete value is equal to 100.

     

    1. This is how the all Items View looks before update

    updateviewquery.png

    2. This is what we are aiming for after the update with the Power Automate cloud flow

    updateviewquery02.png

     

    3. The ViewQuery you would need to achieve this would be like below:

     

    <OrderBy><FieldRef Name=\"DueDate\" /></OrderBy><Where><Neq><FieldRef Name=\"PercentComplete\" /><Value Type=\"Number\">100</Value></Neq></Where>

     

    4. In a flow setup it would look like the below

    Be sure to use your specific ViewId, not the one of my example.

     

    URI

    _api/web/lists/getByTitle('@{variables('ListName')}')/Views('@{variables('ViewId')}')

     

    Headers

    {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json;odata=verbose",
     "X-HTTP-Method": "MERGE"
    }

     

    Body

    { "__metadata": 
    { "type": "SP.View" }, 
    "ViewQuery": "<OrderBy><FieldRef Name=\"DueDate\" /></OrderBy><Where><Neq><FieldRef Name=\"PercentComplete\" /><Value Type=\"Number\">100</Value></Neq></Where>"
    }

     

     

    updateviewquery_flowsetup.png

  • AlexS2023 Profile Picture
    9 on at

    I had a similar query and your solution worked great @Expiscornovus. Is it possible to add additional WHERE clauses? (New to all this and trying to get my head around the syntax!) Thanks.

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @AlexS2023,

     

    Yes, you can use an and element for this. Just add a second clause with <eq> (or neq) directly after the first clause <eq> and place the <and> around it (within the <where>)

     

    Definitely have a look at the CAML query docs from Microsoft, those are a useful resource for this:

    https://learn.microsoft.com/en-us/sharepoint/dev/schema/query-schema

  • Ziryab_J Profile Picture
    2 on at

    Thank you so mucch for your post it works for me but I got an error when trying to open my view :
    the "Specified list is invalid, The specified list might have been deleted or you might not have permission to view it.
    it happens only in that View which contains only one file, but the erreor disapear when I click on the button OK in  the settings page of the view , so i open the settings view page where we put our filters and sorting I click in Ok and the view become accessible again,

    do you have an idea please why it happens ?

     

     

  • wadsywordsy Profile Picture
    2 on at

    Thank you  @Expiscornovus  - I know this is old, but it just saved me from throwing my computer out the window after many hours of going down the wrong path. I'm wondering if there's a way to modify the filters using IN or an OR operator? For example, I've got a variable called strCities and that variable might be "New York" or it might be something like "New York,Los Angeles,Chicago" -- a comma-delimited string. I'm trying to update the view so that it's something like this:

    "ViewQuery": "<Where><In><FieldRef Name=\"City\" /><Value Type=\"String\">strCities</Value></In></Where>"

    ^^That's obviously wrong, but I've been fiddling around with a bunch of different options to no avail. Would really appreciate any help!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard