Wednesday, July 24, 2013

sharepoint designer 2010 task outcome not updated programmatically

I have a scenario where I have to update the task manually with approver's comments using my custom form.Everything works fine but task out come is not updating and task is still showing In Progress ??????
Here is the key to match your code with the following code:
in my case I forgot to update:  taskDataCollection["WorkflowName"] = SPModerationStatusType.Approved;
Following is complete code:

  Hashtable taskDataCollection = new Hashtable();
                    taskDataCollection[SPBuiltInFieldId.Completed] = "TRUE";
                    taskDataCollection["Completed"] = true;
                    taskDataCollection[SPBuiltInFieldId.PercentComplete] = 1.0f;
                    taskDataCollection["PercentComplete"] = 1.0f;
                    taskDataCollection["Status"] = "Completed";
                    taskDataCollection[SPBuiltInFieldId.TaskStatus] = SPResource.GetString(new CultureInfo((int)task.Web.Language, false), Strings.WorkflowStatusCompleted, new object[0]);
                    taskDataCollection[SPBuiltInFieldId.WorkflowOutcome] = outCome;
                    taskDataCollection["TaskStatus"] = outCome;
                    taskDataCollection["TaskOutcome"] = outCome;
                    taskDataCollection["FormData"] = SPWorkflowStatus.Completed; 
                    taskDataCollection["WorkflowName"] = SPModerationStatusType.Approved;

for more info msdn link can also help you .

No comments: