Jun 06 2023 06:53 AM
Hi,
We have created a site where we want to publish news articles to the company. I have added a news web part to the front page but the issue is that if we want to un-puiblish an article, it still appears in the news web part for owners of the site.
For example,
Is this by design? How do un-publish an article for all users? Surely un-publish means hide it from all users.
Dhiran
Jun 07 2023 02:55 AM - edited Jun 07 2023 02:56 AM
Solution@Dhiran Gajjar you don't un-publish the news story, change the version or delete it, you need to demote it from a PromotedState of 2 (published news story) to 0 (normal page). This will remove it from the news web part. To do this, in your site pages library show the Promoted State column. Then format the column in advanced mode and paste in 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"
}
}
}
}
}
]
}
This solution is from Chris Kent on github at https://github.com/pnp/List-Formatting/tree/master/column-samples/promotedstate-demote-news
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)
Jun 07 2023 07:21 AM
Jul 17 2023 03:54 AM - edited Jul 17 2023 04:19 AM
[UPDATE] Ok it apparently takes several tens of minutes to reflect the changes in News webparts.
Hi Rob,
Do you know if that will affect the currently existing News Webpart with that News listed? As per my test, those are still visible in the feeds and it doesn't affect them. Also, I would be careful with anything conected to the Promoted State - some time ago there was a workaround to manipulate those values by displaying and editing the column Promoted State. While per original design, this column was supposed to be read-only. But doing that actually was breaking all the templates on the site, meaning that if there were any News templates saved, they would not reflect Promoted State values while being published, so each one needed to be corrected manually through another workaround.