AI OnAI Off
Hi,
You can load a ContentVersion through the API and there you have DelayPublishUntil. Remember to pass the PageReference/ContentReference with the WorkID as well (it should already be included in contentEventArgs.ContentLink.
Thank you Johan. ContentVersion was the key. This was my solution. If there is a more efficient way to do this, let me know.
private DateTime? GetDelayPublishUntil(ContentEventArgs contentEventArgs) { DateTime? DelayPublishUntil = null; var repository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentVersionRepository>(); if (repository != null) { ContentVersion contentVersion = repository.Load(contentEventArgs.ContentLink); if (contentVersion != null) { DelayPublishUntil = contentVersion.DelayPublishUntil; contentVersion = null; } repository = null; } return DelayPublishUntil; }
When a site administrator edits a page and uses the "Schedule for Publish" option, I need to capture the "Publish changes on" date/time value. Where I'm capturing this is within the context of a Content Event Initializer. Here is part of the helper class I'm using for this:
And this is my checkedInContent event that executes when the "Schedule" button is selected.
My initial solution was to write a method that retrieved the value from the database via the WorkID found in contentEventArgs, via:
And later I appended that WorkID to a SQL query, like so, to grab that DelayPublishUntil value from the database.
For a variety of reasons, I really don't like using this approach to retrieve the date-time. Primarily I'm concerned about foreword compatibility. So how can I get that scheduled publish date and time in a more robust manner. Thanks!