SOLVED

Change Promoted State value

Brass Contributor

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 regular Page without using Power Automate or PowerShell?

16 Replies
best response confirmed by Tamras1972 (Brass Contributor)
Solution
The 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.
Below is PowerShell script which require PnP PowerShell module to change the Promoted State of a page in the Site Pages library:

$pageName = "YourPageName.aspx"
$file = Get-PnPFile -Url "/SitePages/$pageName"
$pageItem = Get-PnPListItem -List "Site Pages" -Id $file.ListItemAllFields.Id
$pageItem["PromotedState"] = 0
$pageItem.Update()
Invoke-PnPQuery
Thanks for confirming it. I was hoping there are new developments and/and or easier way to do this since most of the answers I found online where few years old.
Line # 3 gives me an error that I don't know how to resolve (I am new to PNP). I get this error
Get-PnPListItem : Cannot bind parameter 'Id' to the target. Exception setting "Id": "Cannot convert null to type
"System.Int32"."
At line:1 char:49
+ ... eItem=Get-pnpListItem -List "Site Pags" -ID $file.ListItemAllField.id
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Get-PnPListItem], ParameterBindingException
+ FullyQualifiedErrorId : ParameterBindingFailed,PnP.PowerShell.Commands.Lists.GetListItem

@CLHess That's correct, the $file object in the original post doesn't carry the Id of the page so it's passing null to the Get-PnpListItem cmdlet.

 

Assuming you know the name of the page you're wanting to unpublish, you'd be able to retrieve it with the code below without the need for the page Id.

# Get the desired page object
$PostName = "Some Post"
$Page = Get-PnPListItem -List "Site Pages" | Where-Object {$_.FieldValues.Title -eq $PostName}
# Change promoted state and update
$Page["PromotedState"] = 0
$Page.UpdateItem()
Invoke-PnPQuery

 

Hi, @Tamras1972 !

 

Just to counterpoint @Adnan Amin's words, which I'd kindly suggest are a little strong. I say this because you can change this value easily.

 

How Do You Change The Promoted State?

There are a few ways, I will cover the two most obvious ones.

On Any Given Page

The 'Promoted State' is literally available on every site page to change a Site Page to a News page and back again via the fly-outs in the top right.

 

You can also display this column in the Site Page library very easily, see Greg's handy explanation here.

 

Via The SharePoint API

Equally, it can be amended by calls to the API, my recommendation is to use the /ValidateUpdateListItem endpoint when sending.

 

MethodPOST
URISITE/lists/YOUR_PREFERENCE_ON_GETTING_LIST/items(ITEM_NUMBER)/ValidateUpdateListItem
BodySee below table, the SharePoint site doesn't allow code in tables like the Power Platform one. Weird!

 

 

{
  "formValues": [
      {
        "FieldName": "PromotedState", 
        "FieldValue": "1" 
      }
    ], 
  "bNewDocumentUpdate": true 
}

 

 

You may need to ensure that you have specific headers here, I'm not going in to ALL the detail. :)

 

Further Information

Here is a table of the Promoted States:

Promoted StatePage TypePublished Status
0Site PagePublished/Unpublished
1News Page/LinkUnpublished
2News Page/LinkPublished

 

Hope that this helps anyone else that's ended up here. :)

@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"
            }
          }
        }
      }
    }
  ]
}

 

1-SP (1).png

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

 

 

Thank you, this fixed my issue and I've used it several time.

@CLHess @Tamras1972 Anyone looking for a easier solution to change SharePoint news page to site page, check my solution given on below thread:

 

Change SharePoint News Page to Site Page. Hope it helps!


Please consider giving a Like if my post helped you in any way.

@RobElliott  This was one of the smartest things i've seen. I've always built a PA flow with a button in a formatted column. This is so much better. Thanks for sharing. 

Hi, Rob ... yes ... and that is lovely!

 

That said, the Power Automate way allows people to fit it into their automations so that someone doesn't *have* to press a button. I would not have posted it otherwise. :)

This works really well for me - Thank you!

@RobElliott 

 

Can it be done backward? From state 0 to 2?

I 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? :)

@RobElliott This solution is wonderful!

Thank you so much!

@Adnan Amin 

My answer comes late, but I was able to edit this column with the quick edit function. 

1 best response

Accepted Solutions
best response confirmed by Tamras1972 (Brass Contributor)
Solution
The 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.

View solution in original post