通过以下代码控制子流程并添加执行者,但lFlowTask := lSubFlowInfo.EntryFlowTasks.FindFlowTask('GZPJXJLLR')的返回值为空,这句找的环节是指子流程启动环节。
procedure TEJDHPGZKS.FlowBroker1CreateSubFlow(Sender: TObject; Command: TCreateSubFlowCommand);
var
lSubFlowInfo: TSubFlowInfo;
lGUID: string;
lFlowTask : TFlowTask;
sDeptID : String;
sPosiID : String;
sPersID : String;
begin
lGUID := sdsMasterBroker.dataset.fieldbyname('GDH').asstring;
lSubFlowInfo := Command.SubFlowInfos.Add;
lSubFlowInfo.FlowValue.IDs.Add(lGUID); //给子流程的实例传值
lSubFlowInfo.FlowValue.Subject :=lGUID+':'+sdsMasterBroker.dataset.fieldbyname('GZNR').asstring;; //赋子流程主题
//JSDialogs.ShowMsg(lGUID, '');
lFlowTask := lSubFlowInfo.EntryFlowTasks.FindFlowTask('GZPJXJLLR');//根据任务环节查找任务
if lFlowTask <> nil then
begin
lFlowTask.Executors.Clear;
//删除缺省执行者
sPersID := Command.FlowControl.Executor.PersonID;
sDeptID:=Command.FlowControl.Executor.DeptID;
sPosiID:=Command.FlowControl.Executor.PositionID;
lFlowTask.Executors.Add(sDeptID,sPosiID,sPersID);
end;
end; |