SOLVED

SharePoint News and un-publish

Iron Contributor

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,

  1. I create a news articles and publish this version, so its 1.0 in version history
  2. I then make some changes to it and publish it again, this is now 2.0 in version history
  3. I would like to pull this article and un-publish it.
  4. For end users of the site it seems to remove it from the news web part but for owners of the site its still present as its showing the 1.0 article
  5. If I go to version history and delete the 1.0 version, then this is removed for owners in the news web part.

 

Is this by design? How do un-publish an article for all users? Surely un-publish means hide it from all users. 

 

Dhiran

4 Replies
best response confirmed by Dhiran Gajjar (Iron Contributor)
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"
            }
          }
        }
      }
    }
  ]
}

 

 

1-SP.png

 

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)

Hi Rob, Thank you so much for that, works like a treat! Do you know if something similar can be achvieved to transform the first publish date?

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



 

@RobElliott  Thank you for this solution!

 

Microsoft, it would be great if unpublishing something just simply unpublished it, you know? I cannot fathom why this it is so difficult to take something down that is incorrect or was mistakenly published early, or whatever. A simple blog would be a more usable system at this point.

1 best response

Accepted Solutions
best response confirmed by Dhiran Gajjar (Iron Contributor)
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"
            }
          }
        }
      }
    }
  ]
}

 

 

1-SP.png

 

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)

View solution in original post