Updating SharePoint 'Workflow Tasks'

Problems doing the simplest things. I want to update a task created by the CreateTask activity, when the activity is changed. I have the following function, which is run when the Task list item is edited…

private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
SPWeb mySite = new SPSite(workflowProperties.SiteId).OpenWeb(workflowProperties.WebId);
SPList myList = mySite.Lists[workflowProperties.TaskListId];
SPListItem myTask = myList.GetItemById(TaskBeforeProperties.TaskItemId);
SPUser myUser = mySite.AllUsers[e.Identity];
myTask["Assigned To"] = myUser;
myTask.Update();
}

Everything seems okay, but when I call myTask.Update(), I get the exception “An event receiver has cancelled the request.” And I’m damned if I know why.

Advertisement
Updating SharePoint 'Workflow Tasks'

One thought on “Updating SharePoint 'Workflow Tasks'

  1. Anand says:

    Hi Andrew,
    I have been going through your articles on sharepoint for quite a while now. I should admit, they really are informative and educative as well.

    Anyways, just thought of sharing an idea on UpdateTask activity that you have mentioned above. I also faced a similar issue until I defined a New TaskProperties (eg: updatetask_taskproperties) with the TaskID and correlation tokens to the parent CreateTask Activity. Using this workaround, it started working like a charm.

    Hope that helps,

    Regards,
    Anand

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.