Forum Discussion

arine1901's avatar
arine1901
Brass Contributor
May 10, 2024

Unpost as News

How to unpost a page as news in SharePoint Online?

 

  • Rob_Elliott's avatar
    Rob_Elliott
    Bronze Contributor

    arine1901 if it's going to be a regular thing then show the Promoted State column in your site pages library and format it in advanced mode 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 : Draft News' , if(@currentField == 2 , '2 : Published 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",
            "background-color": "=if(@currentField == 0 ,'#ffffff' , if(@currentField == 1, '#fffcec' , if(@currentField == 2 , '#dafffe','') ) )"
          }
        },
        {
          "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 1: Draft News)",
              "style": {
                "padding": "10px 20px 10px 20px",
                "cursor": "pointer"
              },
              "attributes": {
                "class": "ms-bgColor-themeLighter--hover"
              },
              "customRowAction": {
                "action": "setValue",
                "actionInput": {
                  "PromotedState": "1"
                }
              }
            }
          }
        }
      ]
    }

     

    You will then have a button next to each news page and can demote any one with just the click of the button:

     

     

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)

  • Josh_Wickes's avatar
    Josh_Wickes
    Brass Contributor
    You can change the promoted state by saving the column in a view, using quick edit/edit in quick view and changing the promoted state to 0 abd save changes. This will demote the article to a standard page, note that if the page is being displayed in a highlighted content webpart it may require a site crawl to update and stop showing depending on your environment
  • If you have approval flow activated. Simply editing the page and saving as a draft will hide/unpost the news article.

Resources