Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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... support.microsoft.com/kb/2737435 –  Mike Apr 29 '13 at 13:13

1 Answer 1

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

Your Answer

 
discard

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.