Comet Halley
-
12/6/2011 11:29:20 PM
How to AutoPublish a BlogMonth document?
Hi,
Using v5.5 R2. Create a BlogPost by:
var myBlogPost = new CMS.TreeEngine.TreeNode("CMS.BlogPost", tree);
. . . etc . . . fill in properties & various myBlogPost.SetValue("customFieldName", value)
int blogMonthParentNodeID = CMS.WorkflowEngine.DocumentHelper.EnsureBlogPostHierarchy(myBlogPost, blogRootNode, tree);
CMS.WorkflowEngine.DocumentHelper.InsertDocument(myBlogPost, blogMonthParentNodeID, tree);
Thanks to EnsureBlogPostHierarchy(), the API takes care of creating a BlogMonth document automatically if it doesn;t exist yet.
As we need to populate some custom properties, we use CustomTreeNodeHandler.OnBeforeInsert() to fill these custom properties. This has set the Workflow Step of the BlogMonth Document in Edit Step. Then we use CustomTreeNodeHandler.OnAfterInsert() to MoveToNextStep() until the Step reached "Published".
The CMSDesk show Workflow properties as "Published" however the General properties show Published = No. Checking in the Database, the following columns are all NULL: DocumentPublishedVersionHistoryID, DocumentLastPublished, DocumentPublishedVersionHistoryID. If we click on Save, then the document is correctly Published.
Please note: The BlogMonth workflow has the property "Automatically publish changes" checked.
QUESTION: When a BlogMonth document is created automatically by EnsureBlogPostHierarchy(), how to set it to Published status?
Thanks in advance for any help.
|