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

Iron Contributor

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

 

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

1 Reply

Hi @Miguel Lopes Isidoro,

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.

SitePages.png

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