Reassign workflow task using the workflow web service - AlterToDo method


SharePoint provides a web service workflow.asmx. This is available under /_vti_bin/workflow.asmx and provides an operation AlterToDo which enables to update the task and also reassign the tasks.

I recently had a customer who was having issues with the AlterToDo. Customer was calling the AlterToDo method of the workflow.asmx as per the documentation available but the task was not getting reassigned.

On researching further we could see that there is no accurate documentation on the internet for using the AlterToDo method to reassign tasks.

Following is the code sample which calls the AlterToDo method.

               string strURL = "http://sp/documents/doc1.docx";

            // task item id
            int intToDo = 1;

            // Task list id
            Guid GUIDToDoListID = new Guid("{f46aa19e-ea35-4357-80f4-882306a2ebdc}");

             WorkflowService.Workflow client = new WorkflowService.Workflow();

            client.Credentials = CredentialCache.DefaultCredentials;
       

            string strData = "" ; /*Some xml comes here */

            XmlDocument XMLTaskData = new XmlDocument();

            XMLTaskData.LoadXml(strData);

            var data3 = client.AlterToDo(strURL, intToDo, GUIDToDoListID, XMLTaskData);

 

By accurate documentation I am referring to the xml sent to AlterToDo method.

Following is the correct xml to reassign a task.

var strData = @"<my:myFields xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD'>
                        <my:TaskStatus>ReassignTask</my:TaskStatus>
                        <my:Comments></my:Comments>
                        <my:FieldName_DelegateTo>
                            <pc:Person xmlns:pc=""http://schemas.microsoft.com/office/infopath/2007/PartnerControls"">
                            <pc:DisplayName>User 2</pc:DisplayName>
                            <pc:AccountId>contoso\user2</pc:AccountId>
                           <pc:AccountType>User</pc:AccountType></pc:Person>
                        </my:FieldName_DelegateTo>
                        </my:myFields>";

I haven't seen this method being used very widely. But when it is being used it can be a bummer to get this working without the correct xml to reassign tasks.

Thanks to my Escalation Engineer Andy Li for helping in figuring this out.

 

Comments (0)

Skip to main content