I have a customized Approval workflow in Visual Studio, it creates a task per approver, approvers can complete their tasks through the InfoPath form in the browser and the workflow behaves as expected. No problems there.
Now, from outside the workflow, I needed to complete some tasks programmatically if the task was not already completed by the approver.
To do this, I thought of changing the status field of the Task item to “Completed”, as I would update a value for any other list item:
It, in fact, modifies the task to Completed, nonetheless, it doesn’t seem to fire the OnTaskChanged() in the Workflow. By doing this, I could have all the tasks marked as Completed, and the workflow would still says “In progress”.
I spent some time testing and realized that somehow that was not the correct way to update the Task, I had to find some other way.
What I found, is that the correct way to update workflow tasks is by using the AlterTask method of the SPWorkflowTask class. This is the code:
No comments:
Post a Comment