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 / Update sharepoint list...
Power Automate
Unanswered

Update sharepoint list current view (alternating row styles) with http request

(0) ShareShare
ReportReport
Posted on by 136

Hello to everyone.

 

I have a lot of lists in a sharepoint site. Can I update their current view (alternating row styles) with an http request call  without going into one by one and update them by hand?

 

Thank you in advance.

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

    Hi @NickFot,


    Yes that should be possible with three send an http request to SharePoint actions. The first one is to retrieve the list titles (and exclude things like document libraries, system supporting lists). The second one is to retrieve the default view. The third request is to update the CustomFormatter property with the alternating row styles json.

     

    Below is an example

     

    1. Retrieve the lists with a Send an HTTP request to SharePoint action

    a. Use the uri below which only selects lists of basetemplate 100 which are not hidden

    _api/web/lists?$filter=BaseTemplate eq 100 and Hidden eq false&$select=title

    b. Also using the nometadata headers

     

    2. Apply to each loop action

    a. Uses the output of the first action

     

    outputs('Send_an_HTTP_request_to_SharePoint')?['body']['value']

     

     

    3. Second HTTP request to SharePoint action (within the apply to each)

    a. Uses the uri below to retrieve the id of the default list view

    _api/web/lists/getbytitle('@{items('Apply_to_each')['Title']}')/views?$filter=DefaultView eq true&$select=Id

     

    retrievelists.png

     

    4. Third HTTP request to SharePoint action (within the apply to each)

    a. Uses the id of the second action in the URI

    _api/web/lists/getbytitle('@{items('Apply_to_each')['Title']}')/views('@{outputs('Send_an_HTTP_request_to_SharePoint_-_Get_Default_View')?['body']['value'][0]['id']}')

    b. Uses MERGE headers

    c. Uses the payload below for the body field

    { 
    "__metadata": { "type": "SP.View" },
    "CustomFormatter": "{\"additionalRowClass\":{\"operator\":\":\",\"operands\":[{\"operator\":\"==\",\"operands\":[{\"operator\":\"%\",\"operands\":[\"@rowIndex\",2]},0]},\"sp-css-backgroundColor-BgLightGray30\",{\"operator\":\":\",\"operands\":[{\"operator\":\"==\",\"operands\":[{\"operator\":\"%\",\"operands\":[\"@rowIndex\",2]},1]},\"sp-css-backgroundColor-noFill\",\"\"]}]},\"rowClassTemplateId\":\"BgColorAlternateRows\"}"
    }

     

    getdefaultview_updateview.png

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