In the UI you can choose "Schedule for Publish" to publish a change on a block at a later date. How can this be done programatically? Setting a future date for StartPublish doesn't help, there's a save action named SaveAction.DelayedPublish but that doesn't do anything. Further there's a Status property that has the type VersionStatus that can be set to VersionStatus.DelayedPublish but that doesn't do any good either.
No matter how I set my properties I get a new version labled "Draft" if I choose SaveAction.Save and a new version labled "Published" for SaveAction.Publish.
Anyone got any ideas?
OK, I finally found the answer myself.
What was required was a bitwise combination of SaveAction.CheckIn and SaveAction.DelayedPublish. (Which is a bit strange since the SaveAction enum doesn't have any [Flags] attribute.)
((IVersionable)block).StartPublish = scheduleDate;
ServiceLocator.Current.GetInstance<IContentRepository>().Save((IContent)block, SaveAction.CheckIn | SaveAction.DelayedPublish, AccessLevel.NoAccess);
The same goes for pages (but here you can skip the constant castings you're forced to do with blocks since blocks only implement IContent in runtime):
page.StartPublish = scheduleDate;ServiceLocator.Current.GetInstance<IContentRepository>().Save(page, SaveAction.CheckIn | SaveAction.DelayedPublish, AccessLevel.NoAccess);
Can't explain anything about any logic behind any of this. Anyone from EPiServer that can?