Inside the workflow, I want to handle errors, for example, I am not able to find the name of the user to whom I want to assign a task. Thus, the username is not exsist, I am going to notify the administrator by email about this, register it in the history of the workflow and then complete the workflow.
The question is how can I complete the workflow from within the workflow, as if I clicked on the “end workflow” button on the SharePoint web page.
[Update] I tried SPWorkflowManager.CancelWorkflow (), which really cancels the workflow, but not right away. What happens is the code to cancel the launch, but then my workflow continues to create the next task, and then goes into sleep mode when it falls into the following onTaskChanged tasks. Only after he falls asleep does the workflow end, and not when CancelWorkflow is called.
This leads to an obvious problem that I do not want the next task to be created. I call CancelWorkflow because I want it to cancel it there too.
c # workflow sharepoint
Dan revell
source share