I am looking for a solution to end a workflow from code. I have a state machine workflow in nintex. When the workflow is in progress, we need to change the state of this workflow in certain 'special' situations. Currently, we are using below code to cancel existing workflow and then we start a new workflow. The new workflow checks the status of the list item and then switches the state accordingly.
//Cancel existing workflows if any
SPWorkflowCollection existingWorkflows = manager.GetItemActiveWorkflows(item);
foreach (SPWorkflow existingWorkflow in existingWorkflows)
Is there a way to 'Complete' the workflow and not cancel it?