I'm creating a page programmatically (EPiServer version 220.127.116.11), but wish for this page to be saved as a draft rather than be published. I'm struggling to find the SaveAction I need to do this.
The following results in a 'checked-out' page...
_contentRepository.Save(newPage, SaveAction.Save, AccessLevel.NoAccess);
...in which all properties are greyed-out, the yellow "Ready to publish" label is showing and it indicates it is "pending approval".
I've also tried with SaveAction.Save | SaveAction.CheckIn (similar behaviour to the above), and SaveAction.Save | ForceCurrentVersion (which caused an error).
I need the page to be in a draft status, readily editable by any user and not subject to approval process.
Is there something I'm missing?
Thanks in advance!
Save should be the correct one. Do you have any content event listener that might change the action down the pipeline?
I would follow Quans advice and look for any event handlers that is modifying things. Check both the Creating/Created and the Saving/Saved events.
Also, as a reference to other people landing here. Using SaveAction.CheckIn will set the state to "Ready to publish". For CMS v9, SaveAction.Save should create an unpublished, draft version as you are expecting. For newer versions however, SaveAction.Default or SaveAction.CheckOut are the preferred options.