Forum Discussion
Creating a flow to change promoted state of a page
Untuvakana yes this is possible and the flow is shown below. In my example we are changing the Promoted State from 2 to 0 if the Created date is more than 1 month ago and the promoted State equals 2 and the Name column starts with T5.
In the flow use a recurrence schedule as the trigger and then initialize a string variable which will hold the ID number of the page:
Next, add a compose action to get the date 1 month ago. As you will be doing a date comparison in the next step make sure you use the yyyy-MM-dd format:
To make the flow more efficient we only want to get the items where the created date was less than or equal to the output of the previous compose, i.e more than 1 month ago, and the Promoted State equals 2. Make sure you put the output of the previous compose inside single quote marks in your filter query. You won't find the Site Pages library in the dropdown, so go to the bottom of the dropdown, select Custom value and type Site Pages into the field.
Next, add an apply to each and select value from the dynamic content box. Then append the ID of the page to the variable
In this example we are only changing the promoted state for those pages where the name starts with T5, so - still inside the apply to each - add a condition to check this:
You can leave the red if no channel empty as nothing needs to be done if the name doesn't start with T5.
In the green if yes channel add a Send an HTTP request to SharePoint action and
select your site, then:
Method: POST
Uri: _api/Web/Lists/GetByTitle('Site Pages')/Items(@{variables('varID')})
Headers - accept - application/json;odata=verbose
Headers - content-type - application/json;odata=verbose
Headers - If Match - *
Headers - X-HTTP-Method - MERGE
Body - { '__metadata':{'type':'SP.Data.SitePagesItem'},'PromotedState':0 }
Make sure you use 2 underscores before metadata in the body field.
Finally, outside the if yes/if no channels but still inside the apply to each, add a Set variable control and set the value of your variable from the expression tab to null.
Rob
Los Gallardos
Microsoft Power Automate Community Super User