SPWorkflowTask.AlterTask Method
Updates the specified task with the specified property values.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Parameters
- task
- Type: Microsoft.SharePoint.SPListItem
The workflow task to be updated.
- htData
- Type: System.Collections.Hashtable
A hash table with name-value pairs that correspond to field names and new values.
- fSynchronous
- Type: System.Boolean
true to wait up to 30 seconds for the outcome of the attempted update; otherwise false.
Return Value
Type: System.BooleanIf true is passed as the argument to fSynchronous, this method waits up to 30 seconds to determine whether the attempted update was accepted by the workflow schedule as valid. The method then returns true if the update was accepted and not rolled back, or false if the update was not accepted. If false is passed as the argument to fSynchronous, this method always returns true.
| Exception | Condition |
|---|---|
| ArgumentNullException |
The argument to the task parameter is null. |
| NotSupportedException |
The content type of the item passed to the task parameter is not derived from the WorkflowTask content type. |
Don't call update on your item, after calling AlterTask()
If you use this method to change a task, don't call Update() on your item afterwards. The AlterTask() method takes care of this internally, and if you call it a second time immediately after you can run into all sorts of complications.
Here's something I ran into earlier: http://aarebrot.net/blog/2011/10/how-sloppiness-and-spworkflowtask-altertask-could-inadvertantly-lock-your-workflow-task/
- 10/19/2011
- Frode Aarebrot
AlterTask should not be used from within a workflow
This method is for modifying a task from outside the workflow (e.g. from a webpage or webpart). If you want to update a task in the workflow, use the UpdateTask activity.
- 8/26/2010
- Westley -MSFT-