The below back to author code is not working in core service based workflow.
and not giving any error. any suggestions?
public void BackToAuthor(string workitemid)
{
var client = new CoreServiceSession();
var csClient = client.GetClient();
var readoption = new ReadOptions();
var workitem = (WorkItemData)csClient.Read(workitemid, readoption);
var processInstance = (ProcessInstanceData)csClient.Read(
workitem.Process.IdRef, readoption);
var ieActivities = processInstance.Activities;
if (ieActivities != null)
{
var targetactivity = (ActivityInstanceData)csClient.Read(
processInstance.Activities[0].Id, readoption);
var finishData = new ActivityFinishData();
finishData.Message = "Finished automatically";
finishData.NextAssignee = new LinkToTrusteeData {
IdRef = processInstance.Activities[0].Performers[0].IdRef,
Title = processInstance.Activities[0].Performers[0].Title };
csClient.FinishActivity(targetactivity.Id, finishData, readoption);
logdetails("Finished the activity");
csClient.Close();
}
}
I believe you have to send the activity back to the performer not to the owner (which is "everyone" for the very first activity). You might have to change the following lines of code...
finishData.NextAssignee = new LinkToTrusteeData {
IdRef = processInstance.Activities[0].Performer.IdRef,
Title = processInstance.Activities[0].Performer.Title };