Sitecore - Update Workflow History

Can I programmatically set a workflow comment? for example User Admin "Reject" an item from the workspace, we ask for a comment. Our agent later processes this comment and sends an email. Now I need my user module to do the same (admin reject function).

This was the same code that Sitecore used to set up the workflow comment, which I assume ...

+4
source share
1 answer

Below is the code for executing any of the workflow commands, assuming that you know the identifier of the command element:

public bool Execute(Item item, ID commandId, string comment) { var workflowId = item[FieldIDs.Workflow]; if (String.IsNullOrEmpty(workflowId)) { throw new WorkflowException("Item is not in a workflow"); } IWorkflow workflow = item.Database.WorkflowProvider.GetWorkflow(workflowId); var workflowResult = workflow.Execute(commandId.ToString(), item, comment, false, new object[0]); if (!workflowResult.Succeeded) { var message = workflowResult.Message; if (String.IsNullOrEmpty(message)) { message = "IWorkflow.Execute() failed for unknown reason."; } throw new Exception(message); } return true; } 
+3
source

All Articles