Forum Discussion
Tamras1972
Feb 06, 2023Iron Contributor
Change Promoted State value
In Site Pages library, I need to change News (Promoted State =2) to Page (Promoted State = 0) -- however, the Promoted State column is read only. Is there another way to change the page from News to...
- Feb 06, 2023The Promoted State column in the Site Pages library is read-only and it is designed to be set by the system. It is not recommended to manually change the value of the Promoted State column, as this could have unintended consequences.
There is no built-in way to change the Promoted State value without using Power Automate or PowerShell. You could use Power Automate to automate the change of the Promoted State value, or use PowerShell to update the value programmatically.
If you do not want to use Power Automate or PowerShell, you could consider creating a new page and copying the content from the News page to the new page. You can then delete the News page if needed.
RobElliott
Silver Contributor
influentialeliot you don't even need to use the api to change the promoted state from 2 to 0. Just format the Promoted State column with the following JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"flex-wrap": "wrap",
"display": "flex",
"flex-direction": "row"
},
"children": [
{
"elmType": "div",
"txtContent": "=if(@currentField == 0 ,'0 : Page' , if(@currentField == 1, '1 : News (Unpublished)' , if(@currentField == 2 , '2 : News','') ) )",
"style": {
"box-sizing": "border-box",
"padding": "4px 8px 5px 8px",
"display": "flex",
"border-radius": "16px",
"height": "27px",
"align-items": "center",
"white-space": "nowrap",
"overflow": "hidden",
"margin": "4px 4px 4px 4px",
"border": "1px solid"
},
"attributes": {
"class": "=if(@currentField == 0 ,'ms-fontColor-themePrimary ms-borderColor-themePrimary ms-bgColor-white' , if(@currentField == 1, 'ms-fontColor-themePrimary ms-borderColor-themePrimary ms-bgColor-themeLighter' , if(@currentField == 2 , 'ms-fontColor-white ms-borderColor-themePrimary ms-bgColor-themePrimary','') ) )"
}
},
{
"elmType": "div",
"style": {
"font-size": "18px",
"cursor": "pointer",
"padding": "10px",
"border-radius": "50%",
"display": "=if(@currentField == 0 , 'none' ,'')"
},
"attributes": {
"iconName": "MoreVertical",
"class": "ms-fontColor-themePrimary ms-bgColor-themeLighter--hover"
},
"customCardProps": {
"openOnEvent": "click",
"directionalHint": "rightCenter",
"isBeakVisible": true,
"formatter": {
"elmType": "div",
"txtContent": "Demote (Change to 0:Page)",
"style": {
"padding": "10px 20px 10px 20px",
"cursor": "pointer"
},
"attributes": {
"class": "ms-bgColor-themeLighter--hover"
},
"customRowAction": {
"action": "setValue",
"actionInput": {
"PromotedState": "0"
}
}
}
}
}
]
}
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)
dlorenc
Dec 05, 2023Copper Contributor
- M365SpecialistDec 12, 2023Brass ContributorI would also like to alter the code so that you can change the promoted state in any direction, 0,1 or 2. Can you please share a code that can do this? 🙂