Updating a Kentico Document with Workflow
var item = DocumentHelper.GetDocument(NodeID, "en-au", new TreeProvider());
UserInfo u = UserInfoProvider.GetUserInfo("uniondigital");
if (item != null)
{
TreeProvider tree = new TreeProvider(u);// Create an instance of the Tree provider first
if (item != null)
{
bool update = false;
if (!string.IsNullOrWhiteSpace(DocumentPageTitle))
{
if (item.GetStringValue("DocumentPageTitle", "") != DocumentPageTitle)
{
item.SetValue("DocumentPageTitle", DocumentPageTitle);
update = true;
}
}
if (update)
{
WorkflowManager manager = WorkflowManager.GetInstance(tree);//gets the manager
WorkflowStepInfo step = manager.GetStepInfo(item);//finds the workflow step information for the item
if (step != null)
{//only if the document is using workflow than go in
item.CheckOut();// Document must be checked-out manually if check-in/check-out is not used
DocumentHelper.UpdateDocument(item);// Update document
item.CheckIn();// Document must be checked-in manually in order to create new
manager.MoveToSpecificStep(item, step);//puts the document back to the same workflow step
}
else
{
item.Update();
}
}
}
}