在代码中创建流程控制组件(TFlowControl),对流程参数进行赋值,用这个组件来启动流程实例,并且把这个流程实例保存到系统数据库中。
procedure TMainForm.UserStartFlow
(AFlowUrl,ADept,ARole,APerson,AStartProc,AFlowID,ASubject,ADescription:string);
var
lBizURL: TBizURL;
lFlowValue: TFlowValue;
lFlowControl: TFlowControl;
lExecutor: TOrgURL;
begin
lBizURL := TBizURL.Create;
lFlowValue := TFlowValue.Create;
lFlowControl := TFlowControl.Create(Self.Context);
lExecutor := TOrgURL.Create(ADept, ARole, APerson);
lBizURL.URL := AFlowUrl;
try
lFlowValue.IDs.Add(AFlowID); //流程ID
lFlowValue.Subject := ASubject; //流程主题
lFlowValue.Description := ADescription; //流程描述
//启动流程实例
lFlowControl.StartupFlow(lBizURL, AStartProc, lExecutor, lFlowValue);
//流程实例数据保存到数据库
lFlowControl.FlowRunnerbyIndex[0].CurrentTask.SaveToDB;
finally
lFlowControl.Free;
lFlowValue.Free;
lBizURL.Free;
end;
end; |