News Post Stuck in Hub Site’s News Web Part Even After Deletion
This is something that’s happened to me in multiple tenants recently. When I delete a News Post which I’ve created in a Hub Site, the post never goes away in the News Web Part. It always seems to be a post we’ve created as some sort of point-proving demo, too. You know, with a title like: “This would be a really helpful news post” or “Be sure to delete me.”
Was there a trick was missing? I’ve tried reindexing, emptying the recycle bin, everything I could think of, but no joy.
The light finally came on when I posted to #SPHelp on Twitter and got this response from my pal Sharon Weaver (@shareoneweaver).
When PromotedState
is 2, the page is a News Post. When it’s 0, the page is just a page. So, in effect, you want to remove the “newsiness” from the page. Then you can get rid of it with impunity.
Thing is, you can’t edit PromotedState
through the UI anymore. But I had a solution!
No surprise, but ShareGate to the rescue. I exported the metadata for the page, edited PromotedState
value from 2 to 0 in Excel, imported the change to PromotedState
, manually kicked off a reindex of the library – and the pesky News Post is gone from the News Web Part!
Not trivial, but it worked. It’s a bug.
Maybe not much easier, but you can also use powershell to change any of those “read only” fields:
$SiteURL= “https://xxx.sharepoint.com/sites/xxx”
$ListName = “SitePages”
$ItemID = “xxx”
$PromotedState = “0”
Connect-PnPOnline -Url $SiteURL -UseWebLogin
Set-PnPListItem -List $ListName -Identity $ItemID -Values @{“PromotedState”=$PromotedState}
I keep this in a local file, update it and run it when necessary.
Yeah, I was hoping for a “real person” solution. Better yet, that this just get fixed.
Already exist “real person” solution customization for this…
https://github.com/pnp/List-Formatting/tree/master/column-samples/promotedstate-demote-news
Now…, how to fix this if you deleted that page from the second stage recycle bin? BTW this bug also presen if you use a link to a newspost or delete a news post from a site connected to the hub. Google learns me that this bug is already two years old :(
Any ideas in the meantime?
Unfortunately, if you’ve fully deleted the page, then it’s gone.
It’s incorrect that you can’t edit the Promoted State through the UI. You can. In the list view edit the Promoted State column and change the default value from 2 to 0 and save. Then edit it again and change the default value from 0 to 2 and save. You will find that the Promoted State of all items can now be changed, e.g. in Grid View.
Good catch, Rob!
What do you mean with “the list view”? I get the message that the column is read-only and in the details pane the field doesn’t show up.
I’ve found that if you select the page in the Site Pages library, you can use the ellipses menu to select “more” and then choose “unpublish” and this removes the news post both from the site it was posted on and the news web part on the home page. Interestingly it doesn’t change the Promoted State number associated with the page, but it does the trick of removing the news post.
This is a good alternative:
https://techcommunity.microsoft.com/t5/sharepoint/change-promoted-state-value/m-p/3735300
In this article, you can use advanced custom formatting using JSON for the column. The custom format gives you three dots for the column and allows you to change the value from 2 to 0. You cannot change it back.
OY Microsoft!
Here is the 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”
}
}
}
}
}
]
}