Trying to save new page as draft - what SaveAction do I need?

Vote:
 

I'm creating a page programmatically (EPiServer version 9.10.2.0),  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!

#196669
Edited, Sep 06, 2018 15:43
Vote:
 

Save should be the correct one. Do you have any content event listener that might change the action down the pipeline?

#196672
Sep 06, 2018 16:52
Vote:
 

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.

#196675
Sep 07, 2018 0:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.