API Questions on Kentico API.
Version 5.x > API > How to AutoPublish a BlogMonth document? View modes: 
User avatar
Member
Member
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.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/9/2011 1:24:11 AM
   
RE:How to AutoPublish a BlogMonth document?
Hi,

In the other thread I posted some links to the API examples (thread).

What you described here sounds OK but, could you please post the exact code you are using and also where exactly is is being used? How are you getting the month document? When you run it in debug mode - is the correct document available in the code?

Best regards,
Juraj Ondrus

User avatar
Member
Member
Comet Halley - 12/12/2011 8:30:35 PM
   
RE:How to AutoPublish a BlogMonth document?
Hi,

Moving the Workflow steps WON'T fix the AutoPublish of Blog Month. I described the solution in the following post: "Workflow setting "Automatically publish changes" not working?"

(Read message #7)
http://devnet.kentico.com/Forums/f54/fp1/t24668/Workflow-setting--Automatically-publish-changes---.aspx