Hi,
My workflow starts whenever a new item is added in a list.
It can happen than two items fire two same tasks (Assignment for Project X). If I fill the first task and complete it, the workflow of the first item will be ok but not the workflow of the second item will be stuck because the second task is not completed yet.
That's why I would like to just "update" it or to make it to Completed, but it does not work.
I have searched and couldn't find a solution...
I have tried this code:
Hashtable ht = new Hashtable(); ht[SPBuiltInFieldId.Completed] = "TRUE"; //=true; ht[SPBuiltInFieldId.PercentComplete] = (float) 1.0f; SPWorkflowTask.AlterTask(incidentItem, ht,false);
but it throws an SPException: This task is currently locked by a running workflow and cannot be edited.
I have also tried editing the WorkflowVersion before the call of AlterTask method
incidentItem[SPBuiltInFieldId.WorkflowVersion] = 1;
Now I have got another error: Task update was not accepted. To edit a task associated with a workflow task process, you must be the person to whom the task is currently assigned.
I was assigned to both of the tasks.
Another solution was not to use the AlterTask method:
incidentItem[SPBuiltInFieldId.WorkflowVersion] = 1; incidentItem["Status"] = "Completed"; //incidentItem[SPBuiltInFieldId.TaskStatus] = SPResource.GetString(new CultureInfo((int)workflowProperties.Web.Language, false), "WorkflowTaskStatusComplete", new object[0]); incidentItem.SystemUpdate();
The Status of the second task is updated. However, the task is not really completed because the other fields (outcome, %, ...) are not filled and it does not trigger the other events of the workflow.
I do not know what is the solution. I just need to "update" the task, with nothing too in order to the workflow to continue.
Does Someone have a workaround for this ?