Skip to main content

Notifications

Community site session details

Community site session details

Session Id : m+O7D5f2hMduOyueR/eFom
Power Automate - Building Flows
Unanswered

Dynamically create a SharePoint List AND format it with a button to trigger another flow

Like (0) ShareShare
ReportReport
Posted on 12 Apr 2023 02:26:27 by 18

Hi everyone,

 

TL;DR: How do I format SharePoint Lists created through HTTP Request during a flow?

 

My goal is to create a new SharePoint List with advanced view formatting with a Flow in Power Automate. 

 

I might be over-complicating what I want to do, but here is the context:

 

This is a flow that triggers when an item is added to my SharePoint List and creates another List and links back to it.

I got that part done using HTTP requests.

 

Here is my current flow.

sergio_flows_3-1681262495361.png

This is the body of the HTTP request:

sergio_flows_4-1681262561316.png

 

The next part would be to format the new SharePoint List view to include a new button in the command bar that, when clicked triggers another Flow that will allow me to add multiple copies of the same record when specified. For example:

     The new button would prompt to a formatted record entry form that would ask for the following fields:

 

     Input

          Number of vials: 3

          Reagent: Cell Culture Media

          Location: Lab1

          Expiration: 04/20/2023

 

     Output

          Item Name, Location, Expiration

          Cell Culture Media, Lab1, 04/20/2023

          Cell Culture Media, Lab1, 04/20/2023

          Cell Culture Media, Lab1, 04/20/2023

 

      This entry will add 3 items (ie. 3 rows) to the new SharePoint List. All with the same data (different autogenerated IDs of course).

 

The main problem for me is that I want to do this by formatting the view and/or column at the moment of making the new SharePoint List, modifying this section:

sergio_flows_5-1681264235300.png

 

Is this possible?

 

Some workarounds I've thought of are:

      1. Create a base template myself for the new SharePoint List in the folder where they will be created, then make the first flow just copy that template list with a new name whenever a new item is added to the master List.

      2. Make the 2nd Flow trigger automatically when a new item is added to any SharePoint List in the folder where the new Lists will be saved, forgetting about formatting and adding the new button to the new SharePoint List dynamically.

 

Thank you!

 

  • sergio_flows Profile Picture
    18 on 14 Apr 2023 at 18:41:07
    Re: Dynamically create a SharePoint List AND format it with a button to trigger another flow

    Hey @Expiscornovus ,

     

    This is really helpful, I didn't know there was an endpoint method to update the XML files from power automate.

    I tried what you suggested and the flow runs successfully, but I still can't see the alternating row formatting on this test list. See:

    sergio_flows_0-1681493872251.png

    (I made sure to name my variables the exact same as yours).

     

    Two follow up questions:

     

    1. Where can I find more complete documentation about the API endpoint methods? For example, the SetViewXml method is not mentioned in the docs for SharePoint as far as I can see .

     

    2. Is is possible to set the entire XML structure, including multiple fields, and view using only 1 post request? That way I wouldn't have to make multiple HTTP request in succession to add every field (I need to add 5) and then an extra one to edit the view.

     

    Thanks!

     

    PS: just subscribed to your channel

     

     

  • Expiscornovus Profile Picture
    31,643 Most Valuable Professional on 12 Apr 2023 at 09:42:29
    Re: Dynamically create a SharePoint List AND format it with a button to trigger another flow

    Hi @sergio_flows,

     

    You can use a setviewxml method to update the customformatter property of your newly created view.


    Below is an example

    In this example I am setting the alternating row styles formatting.

     

    Payload Body

    {"viewXml":"<View Name=\"{@{variables('ViewId')}}\" Type=\"HTML\" DisplayName=\"Formatted View\" Url=\"/sites/PowerUsers/@{variables('ListName')}/Forms/Formatted View.aspx\" Level=\"1\" BaseViewID=\"1\" ContentTypeID=\"0x\" ImageUrl=\"/_layouts/15/images/dlicon.png?rev=47\"><Query/><ViewFields><FieldRef Name=\"DocIcon\"/><FieldRef Name=\"LinkFilename\"/><FieldRef Name=\"Modified\"/><FieldRef Name=\"Editor\"/><FieldRef Name=\"ID\"/></ViewFields><RowLimit Paged=\"TRUE\">30</RowLimit><JSLink>clienttemplates.js</JSLink><XslLink Default=\"TRUE\">main.xsl</XslLink><CalendarViewStyles><CalendarViewStyle Title=\"Day\" Type=\"day\" Template=\"CalendarViewdayChrome\" Sequence=\"1\" Default=\"FALSE\"/><CalendarViewStyle Title=\"Week\" Type=\"week\" Template=\"CalendarViewweekChrome\" Sequence=\"2\" Default=\"FALSE\"/><CalendarViewStyle Title=\"Month\" Type=\"month\" Template=\"CalendarViewmonthChrome\" Sequence=\"3\" Default=\"FALSE\"/></CalendarViewStyles><Toolbar Type=\"Standard\"/><CustomFormatter><![CDATA[{\"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\"}]]></CustomFormatter></View>"}

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started