I was asked by one of my colleagues on how to have access to the name of the user who is modifying a task programmatically within the Workflow code. Every time a task gets modified by a user (SPTaskProperties.AssignedTo) the OnTaskChanged activity populates the OnTaskChanged.ExecutorProperty and the name of the user can be retrieved by referencing this property.
Note:SPWorkflowActivationProperties.Web.CurrentUser.Name has "System Account" as value as by design all custom Workflow instances (Implemented by Visual Studio 2005/2008) run under that account.
Next post: Setting Workflow related properties in MOSS/WSS 3.0 using stsadm.exe
Hi,
Are you able to successfully update a task, I am struggling to do the same. This is what I have tried with nothing working
1. UpdateTask Activity
2. SPWorkflowTask.AlterTask
3. ListItem.Update
4. ListItem.SystemUpdate
It would be great if you could help me as I am tired of hitting the wall.
Thanks,
Nitin Rastogi
For updating a task you should be able to use SPWorkflowTaskProperties to update the task.
Hi Ali,
Thanks for the response. I used the same but it is giving me a weird error : "Correlation value has not been initialized on declaration updateReviewersTask for activity docApprovalActivity.UpdateReviewersTask"
UpdateReviewersTask is an activity of type UpdateTask and it has its own corelation token separate from the CreateTask.
This is the code snippet of what I am trying inside the UpdateTask's method that I am invoking
Dim spworkflowprops As New SPWorkflowTaskProperties
Dim ctask As CreateTask = DirectCast(SequenceActivityForReviewers.Activities(0), CreateTask)
Dim spTaskProps As SPWorkflowTaskProperties = ctask.TaskProperties
m_guidReviewerTaskStatus = Guid.NewGuid()
spworkflowprops.DueDate = DateTime.Today
spworkflowprops.StartDate = DateTime.Today
spworkflowprops.TaskItemId = spTaskProps.TaskItemId
spworkflowprops.TaskType = spTaskProps.TaskType
UpdateReviewersTask.TaskProperties = spworkflowprops
UpdateReviewersTask.TaskId = ctask.TaskId
Is there anything that I am missing ?
Is onWorkflowActivated the first activity in the design mode, also I'd double check the correlation token setting for all the activities, all the task related activities should use the same token.
Thanks a lot for quick response.
Yeah OnWorkflowActivated is the first activity. As you mentioned "all the task related activities should use the same token" I thought so that could be the problem. But then how will I update a task based on TaskChange on some other task ?
I have to update something on Task A from Task B.