Jun 03 2021 01:11 AM
I want to create a flow using power automate that changes site pages promotion stage from 2 to 0 every month if page doesn't consist certain name. This is so pages doesn't show in news feed after certain time but don't be deleted from sharepoint.
How do I change promotional stage in power autome?
Jun 03 2021 04:26 AM - edited Jun 03 2021 04:55 AM
@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
Jun 07 2021 02:50 AM
Jun 07 2021 04:59 AM
Jun 07 2021 05:14 AM
Jun 07 2021 05:43 AM - edited Jun 08 2021 04:47 AM
Dec 24 2021 07:55 AM
This was the only way I could update the PromotedState field:
_api/web/lists/GetByTitle('Site Pages')/items(###)/validateUpdateListItem
{
"formValues": [
{
"FieldName": "PromotedState",
"FieldValue": "2"
}
]
}
Ellis
Feb 21 2023 05:59 PM