Below you can find the code for publishing a document in Kentico.
Below you can find the code for publishing a document in Kentico.
// Initialize the TreeProvider
CMS.SiteProvider.UserInfo ui = CMSContext.CurrentUser;
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(ui);
// Check out the document
CMS.WorkflowEngine.VersionManager vm = new CMS.WorkflowEngine.VersionManager(tree);
vm.CheckOut(node);
// Update the node
node.SetValue("...", "...");
DocumentHelper.UpdateDocument(node, tree);
// Check in the document
vm.CheckIn(node, null, null);
// Get the current step of the document
CMS.WorkflowEngine.WorkflowManager wm = new CMS.WorkflowEngine.WorkflowManager(tree);
CMS.WorkflowEngine.WorkflowStepInfo currentStep = wm.GetStepInfo(node);
// Loop through the steps and publish the document
while ((currentStep != null) && (currentStep.StepName.ToLower() != "published"))
{
currentStep = wm.MoveToNextStep(node, "");
}