Creating a flow to change promoted state of a page

%3CLINGO-SUB%20id%3D%22lingo-sub-2411565%22%20slang%3D%22en-US%22%3ECreating%20a%20flow%20to%20change%20promoted%20state%20of%20a%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2411565%22%20slang%3D%22en-US%22%3E%3CP%3EI%20want%20to%20create%20a%20flow%20using%20power%20automate%20that%20changes%20site%20pages%20promotion%20stage%20from%202%20to%200%20every%20month%20if%20page%20doesn't%20consist%20certain%20name.%20This%20is%20so%20pages%20doesn't%20show%20in%20news%20feed%20after%20certain%20time%20but%20don't%20be%20deleted%20from%20sharepoint.%3C%2FP%3E%3CP%3EHow%20do%20I%20change%20promotional%20stage%20in%20power%20autome%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2411565%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPages%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPages%20Library%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20Automate%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2412142%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20flow%20to%20change%20promoted%20state%20of%20a%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2412142%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1009245%22%20target%3D%22_blank%22%3E%40Untuvakana%3C%2FA%3E%26nbsp%3Byes%20this%20is%20possible%20and%20the%20flow%20is%20shown%20below.%20In%20my%20example%20we%20are%20changing%20the%20Promoted%20State%20from%202%20to%200%20if%20the%20Created%20date%20is%20more%20than%201%20month%20ago%20and%20the%20promoted%20State%20equals%202%20and%20the%20Name%20column%20starts%20with%20T5.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%220-SP-SitePages.png%22%20style%3D%22width%3A%20843px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285908i22388639DA5B04C5%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%220-SP-SitePages.png%22%20alt%3D%220-SP-SitePages.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3BIn%20the%20flow%20use%20a%20recurrence%20schedule%20as%20the%20trigger%20and%20then%20initialize%20a%20string%20variable%20which%20will%20hold%20the%20ID%20number%20of%20the%20page%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%221-Flow.png%22%20style%3D%22width%3A%20632px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285910i482F2F68F93408E8%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%221-Flow.png%22%20alt%3D%221-Flow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENext%2C%20add%20a%20compose%20action%20to%20get%20the%20date%201%20month%20ago.%20As%20you%20will%20be%20doing%20a%20date%20comparison%20in%20the%20next%20step%20make%20sure%20you%20use%20the%20yyyy-MM-dd%20format%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%222-Flow.png%22%20style%3D%22width%3A%20875px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285911i628D87AAA77C7F05%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222-Flow.png%22%20alt%3D%222-Flow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20make%20the%20flow%20more%20efficient%20we%20only%20want%20to%20get%20the%20items%20where%20the%20created%20date%20was%20less%20than%20or%20equal%20to%20the%20output%20of%20the%20previous%20compose%2C%20i.e%20more%20than%201%20month%20ago%2C%20%3CU%3Eand%3C%2FU%3E%20the%20Promoted%20State%20equals%202.%20Make%20sure%20you%20put%20the%20output%20of%20the%20previous%20compose%20inside%20single%20quote%20marks%20in%20your%20filter%20query.%20You%20won't%20find%20the%20Site%20Pages%20library%20in%20the%20dropdown%2C%20so%20go%20to%20the%20bottom%20of%20the%20dropdown%2C%20select%20Custom%20value%20and%20type%20Site%20Pages%20into%20the%20field.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%223-Flow.png%22%20style%3D%22width%3A%20625px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285909i812441099E68AA6B%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%223-Flow.png%22%20alt%3D%223-Flow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3BNext%2C%20add%20an%20apply%20to%20each%20and%20select%20value%20from%20the%20dynamic%20content%20box.%20Then%20append%20the%20ID%20of%20the%20page%20to%20the%20variable%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%224-Flow.png%22%20style%3D%22width%3A%20658px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285912iD44DD15167E0E864%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%224-Flow.png%22%20alt%3D%224-Flow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20this%20example%20we%20are%20only%20changing%20the%20promoted%20state%20for%20those%20pages%20where%20the%20name%20starts%20with%20T5%2C%20so%20-%20still%20inside%20the%20apply%20to%20each%20-%20add%20a%20condition%20to%20check%20this%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%225a-Flow.png%22%20style%3D%22width%3A%20538px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285915iA57E16DD689D42AB%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%225a-Flow.png%22%20alt%3D%225a-Flow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3BYou%20can%20leave%20the%20red%20if%20no%20channel%20empty%20as%20nothing%20needs%20to%20be%20done%20if%20the%20name%20doesn't%20start%20with%20T5.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20green%20if%20yes%20channel%20add%20a%20Send%20an%20HTTP%20request%20to%20SharePoint%20action%20and%20select%20your%20site.%3C%2FP%3E%3CP%3Eselect%20your%20site%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMethod%3A%20POST%3CBR%20%2F%3EUri%3A%26nbsp%3B_api%2FWeb%2FLists%2FGetByTitle('Site%20Pages')%2FItems(%40%7Bvariables('varID')%7D)%3C%2FP%3E%3CP%3EHeaders%20-%20accept%26nbsp%3B%20-%20application%2Fjson%3Bodata%3Dverbose%3C%2FP%3E%3CP%3EHeaders%20-%20content-type%20-%26nbsp%3Bapplication%2Fjson%3Bodata%3Dverbose%3C%2FP%3E%3CP%3EHeaders%20-%20If%20Match%20-%20*%3CBR%20%2F%3EHeaders%20-%20X-HTTP-Method%20-%20MERGE%3C%2FP%3E%3CP%3EBody%20-%26nbsp%3B%7B%20'__metadata'%3A%7B'type'%3A'SP.Data.SitePagesItem'%7D%2C'PromotedState'%3A0%20%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMake%20sure%20you%20use%202%20underscores%20before%20metadata%20in%20the%20body%20field.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%226-Flow.png%22%20style%3D%22width%3A%20783px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285914i18E3F2621647C352%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%226-Flow.png%22%20alt%3D%226-Flow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2421355%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20flow%20to%20change%20promoted%20state%20of%20a%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2421355%22%20slang%3D%22en-US%22%3EWhen%20I%20try%20to%20run%20this%20and%20condition%20is%20true%20I%20get%20this%20error%20message%3A%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22message%22%3A%20%22Request%20ETag-value%20'%20'%20doesn't%20match%20with%20object%20ETag%20'%5C%22c11dd47d-90dc-4a84-b222-492ad9feb4af%2C12%5C%22'.%5Cr%5CnclientRequestId%3A%20e310ef09-909c-42c5-9a3b-cb2298dfa355%5Cr%5CnserviceRequestId%3A%202180cf9f-5002-3000-0498-428ab618e0d4%22%2C%3CBR%20%2F%3E%22status%22%3A%20412%2C%3CBR%20%2F%3E%22source%22%3A%20%3CA%20href%3D%22https%3A%2F%2Fxxxxxxxx%2F_api%2Fweb%2Flists%2FGetByTitle('Site%2520Pages')%2FItems(31%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fxxxxxxxx%2F_api%2Fweb%2Flists%2FGetByTitle('Site%2520Pages')%2FItems(31%3C%2FA%3E)%2C%3CBR%20%2F%3E%22errors%22%3A%20%5B%3CBR%20%2F%3E%22-1%22%2C%3CBR%20%2F%3E%22Microsoft.SharePoint.Client.ClientServiceException%22%3CBR%20%2F%3EError%20message%20was%20in%20another%20language%20so%20sorry%20for%20rough%20translation.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2421695%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20flow%20to%20change%20promoted%20state%20of%20a%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2421695%22%20slang%3D%22en-US%22%3EIf%20you%20can%20post%20screenshots%20of%20your%20flow%20I'll%20take%20a%20look%20and%20see%20if%20I%20can%20see%20what's%20causing%20that.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2421713%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20flow%20to%20change%20promoted%20state%20of%20a%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2421713%22%20slang%3D%22en-US%22%3EThanks%2C%20I%20was%20just%20careless%20and%20missed%20one%20typing%20error.%20Now%20the%20script%20runs%20fine%20and%20no%20errors%20but%20when%20I%20go%20back%20to%20Sharepoint%20every%20item%20that%20script%20found%20is%20still%20in%20promoted%20state%202.%3C%2FLINGO-BODY%3E
Occasional Contributor

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?

5 Replies

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

 

0-SP-SitePages.png

 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:

1-Flow.png

 

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:

2-Flow.png

 

 

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.

3-Flow.png

 Next, add an apply to each and select value from the dynamic content box. Then append the ID of the page to the variable

4-Flow.png

 

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: 

5a-Flow.png

 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.

 

6-Flow.png

 

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

When I try to run this and condition is true I get this error message:
{
"message": "Request ETag-value ' ' doesn't match with object ETag '\"c11dd47d-90dc-4a84-b222-492ad9feb4af,12\"'.\r\nclientRequestId: e310ef09-909c-42c5-9a3b-cb2298dfa355\r\nserviceRequestId: 2180cf9f-5002-3000-0498-428ab618e0d4",
"status": 412,
"source": https://xxxxxxxx/_api/web/lists/GetByTitle('Site%20Pages')/Items(31),
"errors": [
"-1",
"Microsoft.SharePoint.Client.ClientServiceException"
Error message was in another language so sorry for rough translation.
If you can post screenshots of your flow I'll take a look and see if I can see what's causing that.
Thanks, I was just careless and missed one typing error. Now the script runs fine and no errors but when I go back to Sharepoint every item that script found is still in promoted state 2.

I don't know why it doen't change promotion state but it works in every other part..

Screenshot 2021-06-07 151849.png2.pngScreenshot 2021-06-07 152019.png4.png

@RobElliott