I have a couple of workflows that are out of sync, so I exectued the following command:
nwadmin -o syncterminatedworkflows -url {myUrl} -verbose -showMissingItems -terminateDeletedItems
When I go to View Workflow History of the site, I see that I have no running workflows.
When I go to All site content > Workflows, I see a lot of active workflows. When I click on one of the workflows, I see that the status is "Failed on Start (retrying)", but in the history, the last message is "Workflow was canceled by Systemaccount".
As I was curious how the command works, I used Reflector to see what happens. When the command executes and decides to cancel or terminate a workflow instance, the function CancelWorkflow is called. This function however, only seems to add a history entry to the workflow instance.
private void CancelWorkflow(SPWeb web, Guid instanceId) { try { SPWorkflow.CreateHistoryEvent(web, instanceId, 3, web.CurrentUser, TimeSpan.MinValue, string.Empty, string.Format("Workflow was canceled by {0}.", web.CurrentUser.Name), "{8B292400-8EF9-458d-972A-3F1F203D4577}"); } catch (ArgumentNullException) { WorkflowInstance.CloseInstance(web, instanceId, SPWorkflowState.Cancelled); } } |