SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my code to programmatically alter the task at hand, the only problem is that the code doesn't alter the "Outcome" of the approval task. The Outcome field is blank. "Task Status" is Complete, but the Outcome is empty for that task under the workflow status.

Also, under the Task list, the task at hand is 100% complete and set to Completed

Hashtable data = new Hashtable();
            data["FormData"] = SPWorkflowStatus.Completed;
            data[SPBuiltInFieldId.Completed] = "TRUE";
            data["Completed"] = "TRUE";
            data[SPBuiltInFieldId.PercentComplete] = 1.0f;
            data["PercentComplete"] = 1.0f;
            data["Status"] = "Completed";
            data[SPBuiltInFieldId.TaskStatus] = SPResource.GetString(new CultureInfo((int)task.Web.Language, false),
                                                                    Strings.WorkflowStatusCompleted, new object[0]);
            data[SPBuiltInFieldId.WorkflowOutcome] = "Approved";
            data["TaskStatus"] = "Approved"; 
            data["ows_FieldName_Comments"] = "Approved by " + user.Name + "\n";
            web.AllowUnsafeUpdates = true;
            SPWorkflowTask.AlterTask(task, data, true);
share|improve this question
were you able to get this working? – Ryan Erickson Apr 26 '13 at 22:00
No, something leads me to believe it is the build I have that prevents these changes... – Mike Apr 29 '13 at 13:13

I was able to get this working using this blog and I think you have the incorrect assignment to data["TaskStatus"].

Set ht["TaskStatus"] = "#" to set task outcome as “Approved”
Set ht["TaskStatus"] = "@" to set task outcome as “Rejected”

    // alter the task
    Hashtable ht = new Hashtable();
    ht["Status"] = "Complete";
    ht["PercentComplete"] = 1.0f;
    ht["TaskStatus"] = "#";
    SPWorkflowTask.AlterTask((taskedit as SPListItem), ht, true);
share|improve this answer
tried both ways... – Mike Apr 29 '13 at 13:12

In SharePoint 2013 there is no need to use alter the task.

Directly access the list Workflow Tasks and update the item. Following code worked for me:

using (SPSite _site = new SPSite(spSiteURL))
                    using (SPWeb _web = _site.OpenWeb())
                            _site.AllowUnsafeUpdates = true;
                            SPList _taskList = _web.Lists[spTaskListName];
                            SPListItem _taskItem = _taskList.GetItemById(8);
                            if (_taskItem != null)
                                _web.AllowUnsafeUpdates = true;
                                _taskItem["TaskOutcome"] = "Approved";
                                _taskItem["PercentComplete"] = "1";
                                _taskItem["Status"] = "Completed";
                                _web.AllowUnsafeUpdates = false;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.