Forum Discussion

grant_jenkins's avatar
grant_jenkins
Steel Contributor
Sep 30, 2022

Change Published Date for News Post

We are converting some old announcements to News Posts and need to ensure that the Published Date is the same as what they were before.

 

We can use PowerShell to change the First Published Date which is used to order the posts in a News Webpart, but the date that is shown at the top of the News Post itself uses another internal/hidden field called Published Date (or something like that). We can't find a way to change this. So the First Published Date is fine, but can't get it to show that date on the actual News Post.

 

Any ideas more than welcome.

 

 

  • grant_jenkins Are you talking about Publish Start Date?

     

    You can add publish start date column to library view and then user below JSON formatting code on this column to edit date: 

     

    {
      "elmType": "div",
      "inlineEditField": "@currentField",
      "txtContent": "@currentField"
    }

     


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • grant_jenkins's avatar
      grant_jenkins
      Steel Contributor

      Hi,

      No this is not what I'm talking about. I'm talking about what's displayed on the actual News Post beneath the title as per the image - not what you can see in the list view.

      There are two dates that drive a News Post - Publish Start Date (FirstPublishedDate) is set when you first publish the News Post, but the actual Published Date (Hidden field) is generated each time you publish the News Post. I want that to be changed to an older date (the date of the old announcements I'm converting to a News Post).

      Have another look at the image I put in my first post and you'll see what I mean.

      • ganeshsanap's avatar
        ganeshsanap
        MVP

         

        grant_jenkins As per the post - EDIT ORIGINAL PUBLISHING DATE IN SHAREPOINT NEWS POSTS:

         

        Unfortunately, I have not found a way to update or replace the Publishing Date value with the First Publishing Date. For some reason this value cannot be updated and SystemUpdate also doesn’t work. While looking for the solution I think I read that it can be done using ShareGate, but I haven’t tried it.

         

        Also check below thread using C# to update published date which might help you: How to display published date column in document library 


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • NThoman's avatar
    NThoman
    Iron Contributor
    I just ran into this same problem. I had a large news post from a couple of years ago. I created a copy of it because I wanted to send out a reminder email about one piece of it. I edited the new post by deleting the content I didn't need anymore. Then published it as a new news post. However, the first published date is still showing the old date so the news post isn't showing up on the Hub or Team site unless I scroll all the way back to the original year source article was posted.
    • NThoman's avatar
      NThoman
      Iron Contributor
      Update! Just found this post.
      https://babakdanyal.com/edit-original-publishing-date-in-sharepoint-news-posts/

      #start region
      #
      # Editable Published Date OR First Published Date - Use this script to update the original published date of news articles in the SharePoint site.
      #
      #end region
      $SiteURL = "<site url goes here>"
      $ListName= "Site Pages"
      $Date = "2019-12-20"
      $NewsID = 10
      Connect-PnPOnline -Url $SiteURL -Interactive

      if (-not (Get-PnPContext)) {
      Write-Host "Error connecting to SharePoint Online, unable to establish context" -foregroundcolor black -backgroundcolor Red
      return
      }
      else{
      Set-PnPListItem -List $ListName -Identity $NewsID -Values @{"FirstPublishedDate"=$Date;} -UpdateType SystemUpdate
      }
      • micahwilli's avatar
        micahwilli
        Copper Contributor
        We have to do all this to enable what every. other. blog platform already does out of the box?
  • dalonsos's avatar
    dalonsos
    Copper Contributor

    grant_jenkins I found a shortcut using the promoted status column
    If you change the page to promoted status 0, then change it to 1 (unpublished news) and publish the news again, then the "first publication date" is changed to current date.

    In order to modify the promoted status column from the web interface I use this json like column format:  (change Spanish labels to English)

    {
    "elmType": "div",
    "style": {
    "flex-wrap": "wrap",
    "display": "flex",
    "flex-direction": "row"
    },
    "children": [
    {
    "elmType": "div",
    "txtContent": "=if(@currentField == 0 ,'0 : Página normal' , if(@currentField == 1, '1 : Noticia (SinPublicar)' , if(@currentField == 2 , '2 : Noticia Publicada','') ) )",
    "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": "25%",
    "display": "=if(@currentField == 2 || @currentField == 1 , 'none' ,'')"
    },
    "attributes": {
    "iconName": "MoreVertical",
    "class": "ms-fontColor-themePrimary ms-bgColor-themeLighter--hover"
    },
    "customCardProps": {
    "openOnEvent": "click",
    "directionalHint": "rightCenter",
    "isBeakVisible": true,
    "formatter": {
    "elmType": "div",
    "txtContent": "Cambiar a 1: Noticia Sin Publicar",
    "style": {
    "padding": "10px 20px 10px 20px",
    "cursor": "pointer"
    },
    "attributes": {
    "class": "ms-bgColor-themeLighter--hover"
    },
    "customRowAction": {
    "action": "setValue",
    "actionInput": {
    "PromotedState": "1"
    }
    }
    }
    }
    },
    {
    "elmType": "div",
    "style": {
    "font-size": "18px",
    "cursor": "pointer",
    "padding": "10px",
    "border-radius": "25%",
    "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": "Cambiar a 0: Página normal",
    "style": {
    "padding": "10px 20px 10px 20px",
    "cursor": "pointer"
    },
    "attributes": {
    "class": "ms-bgColor-themeLighter--hover"
    },
    "customRowAction": {
    "action": "setValue",
    "actionInput": {
    "PromotedState": "0"
    }
    }
    }
    }
    }
    ]
    }

     

Resources