Forum Discussion

miguelisidoro's avatar
miguelisidoro
Iron Contributor
Feb 11, 2022

SharePoint Online - Enable Scheduling via CSOM on Modern Pages (Site Pages)

Hello,

 

Now we can enable Scheduling on Modern Site Pages:

 

https://support.microsoft.com/en-us/office/schedule-a-sharepoint-page-or-news-post-to-go-live-at-a-specific-time-4b81873c-9bbc-4307-b7ea-7b6662ff1af2

 

I was looking at the CSOM API and did not find any way to accomplish this programmatically?

 

Does anyone know how to accomplish this?

 

If not CSOM, any alternatives? REST API? PnP Provisioning?

 

Thanks

  • AAminM's avatar
    AAminM
    Brass Contributor

    Hi miguelisidoro,

    In case you are still interested in knowing this, or maybe someone else comes across this question. Scheduling publishing for a SharePoint modern page in SharePoint online can be done as follows.

    • Using PNP PowerShell

     

    Connect-PnPOnline https://test.sharepoint.com/sites/test -Interactive
    $page = Get-PnPPage "test.aspx"
    $date = get-date
    $date = $date.AddDays(1)
    $page.SchedulePublish($date)​​

     

    • Using Rest

     

    https://test.sharepoint.com/sites/test/_api/sitepages/pages(6171)/schedulepublish​​

     

            Note: 6171 is the page item Id, which can be found in Site Pages library.

    Moreover, please note that the above REST call works if the page item has values in OData__ScheduledVersion and OData__PublishStartDate. 

    • OData__ScheduledVersion: is the version number to publish, which should be the value of the property owshiddenversion.
    • OData__PublishStartDate: is the publishing date/time

Resources