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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Creating a SharePoint ...
Power Automate
Unanswered

Creating a SharePoint view from Power Automate

(1) ShareShare
ReportReport
Posted on by 21

I have a Flow that is creating a list view in SPO. Here is what is being sent in the body:

"ViewQuery": "<OrderBy><FieldRef Name=\"ID\" Ascending=\"False\" /></OrderBy><Where><And><Eq><FieldRef Name=\"Nomination_x0020_Year\" /><Value Type=\"Text\">2020</Value></Eq><Eq><FieldRef Name=\"Author\" LookupId=\"True\" /><Value Type=\"Lookup\">[Me]</Value></Eq></And></Where>",
 
The view is created successfully but if I look at the view properties it's filtered to Nomination Year equals 2,020 instead of 2020. How do I get it to stop adding a comma? Also, the ID field is still being sorted ascending.
Categories:
  • sasrsc Profile Picture
    678 on at

    Hi Heather...

    1) I'm sorry I don't know the answer to your question other than I've got a date column in my list and I've created a calc column (that is a number) and grabs the year from the date. The format is definitely without a comma.

    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "children": [
    {
    "elmType": "div",
    "txtContent": "=getYear([$EventStart])"
    }
    ]
    }

    sasrsc_0-1598978574891.png


    2) I have a 2nd question - how are you creating the call to create the view. I've been looking around for this "functionality" and have never found it.



  • heatheronder Profile Picture
    21 on at

    It seems to be filtering ok even with the comma oddly enough. It's more of a visual issue.

    I am using "send a custom http request to sharepoint".

     

    heatheronder_0-1598978812742.png

     

  • sasrsc Profile Picture
    678 on at

    Sorry to latch on here Heather, but I'm a novice... did you find any modern example of the http example.. I looked on the Graph API and I couldn't find the "create a view" capability documented. I found this...
    http://blog.techperspect.com/2015/07/create-list-view-using-sharepoint-rest.html

    and https://sharepoint.stackexchange.com/questions/259536/create-list-view-using-rest-api and as far as MS is concerned I found this..
    https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn531433(v=office.15)?redirectedfrom=MSDN#bk_View
    (But they say they are no longer updating this site...)

  • heatheronder Profile Picture
    21 on at

    Those look like they may be the examples I piggy backed off of. I couldn't really find anything 'modern' I just played with it until it worked.

  • sasrsc Profile Picture
    678 on at

    Hi Heather - one more thing...

    I can create the view (thank you).

    But I'm trying to declare which variables I want to see in the view.

    I had assumed that 

    "ViewQuery": "<ViewFields><FieldRef Name=\Title" /><FieldRef Name=\Field2" /> etc... would accomplish that. But when I do that it still includes all the fields...in the view (the filter and sort are working). 

    Am I meant to use ViewData in addition to solve that? In which case, what's the point of adding the fields to the View Query bit?
    ViewData":"<FieldRef Name=\"PercentComplete\" Type=\"StrikeThroughPercentComplete\" /><FieldRef Name=\"DueDate\" Type=\"TimelineDueDate\" />"

    Sorry to be so lame, but if you've gone through this already, I'd rather save my time.
  • heatheronder Profile Picture
    21 on at

    Yeah this solution is definitely not 100%. It seems to use whatever fields are in the current default view when creating the new view. It also doesn't seem to apply the ascending/descending on the sorting properly. I am hoping other people may have a better way to do this.

  • sasrsc Profile Picture
    678 on at

    Understood.

    I have created a power automate http rest to delete all the columns in the view.

    _api/web/lists('@{variables('ListId')}')/Views('@{variables('ViewId')}')/ViewFields/removeallviewfields

    I can then add an individual column back in...
    _api/web/lists('@{variables('ListId')}')/Views('@{variables('ViewId')}')/ViewFields/addViewField('Title')

    But surely I don't have to add each column individually??? Your thoughts..

    This fails...
    _api/web/lists('@{variables('ListId')}')/Views('@{variables('ViewId')}')/ViewFields/addViewField('Title','Favorite Team')

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 377

#2
11manish Profile Picture

11manish 292 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 128

Last 30 days Overall leaderboard