我正在尝试从工作流程发布组件后完成活动。
完成发布,并在设置完成活动消息后收到错误(“对象实例未设置为实例对象”)。
ActivityFinishData activityfinish = new ActivityFinishData();
activityfinish.Message = "Published to WIP Publication Target";
logdetails("Finish Message able to Set using Code,the below is the finish message");
logdetails(activityfinish.Message);
ProcessInstanceData processInstance = new ProcessInstanceData();
ActivityInstanceData activityInstance = (ActivityInstanceData)processInstance.Activities[0];
logdetails(activityInstance.Title.ToString());
logdetails(activityInstance.Id.ToString());
csClient.FinishActivity(activityInstance.Id, activityfinish, readoption);
logdetails("Workflow Finished");
答案 0 :(得分:2)
以下方法对我有用:
SessionAwareCoreServiceClient client = Client.GetCoreService();
ReadOptions options = new ReadOptions();
WorkItemData workItem = (WorkItemData)client.Read(currentWorkItemId, options);
ProcessInstanceData processInstance =
(ProcessInstanceData)client.Read(workItem.Process.IdRef, options);
ActivityInstanceData activityInstance =
(ActivityInstanceData)client.Read(processInstance.Activities[0].Id, options);
ActivityFinishData finishData = new ActivityFinishData();
finishData.Message = "Finished automatically";
client.FinishActivity(activityInstance.Id, finishData, options);
client.Close();
您可以看到我从当前工作项的Id开始并从那里获取现有对象。我创建为“新”的唯一对象是尚不存在的对象。