我想限制执行人的范围, 根据人员的部门和岗位来限定,但是发现如果用FlowBroker1BeforeFlowOut, 就是找不到指定的环节,而如果用FlowBroker1CreateFlowOutFlowTasks事件,就能找到, 我觉得很奇怪,是不是与环境有关呢?
代码如下
procedure TQB_ZPZX.FlowBroker1CreateFlowOutFlowTasks(Sender: TObject; Command: TFlowOutCommand);
var //lDeptID: string;
lFlowTask:TFlowTask;
lexecrange:string;
lperson: string;
begin
lFlowTask:=command.FlowTasks.FindFlowTask('QB_ZX') ;
// lexecrange:='';
// ldeptID:='';
if lflowTask<>nil then //这个事件下,lflowtask是找到了.
begin
// ldeptID:=datasetbroker1.dataset.fieldbyname('ZXBM').asstring; //取得字段内容,为执行部门id串
lflowtask.ProcUnit.ID :='QB_ZX';
lFlowTask.Executors.Clear;
//OrgChildren(OrgKey('lDept', 'JL', '') , '', False, False)
lperson:=
lexecrange:='OrgChildren(OrgKey('''+datasetbroker1.dataset.fieldbyname('ZXBM').asstring+''',''YHBMZH'',''''),'''',false,false)';
lFlowTask.AllowExecutorRange:=lexecrange;
lFlowTask.ExecutorRange:=lexecrange;
end;
end;
procedure TQB_ZPZX.FlowBroker1BeforeFlowOut(Sender: TObject; Command: TFlowOutCommand);
var
lFlowTask:TFlowTask;
lexecrange:string;
begin
lFlowTask:=command.AllowFlowTasks.FindFlowTask('QB_ZX'); //FindFlowTask('QB_ZX') ;
if lflowTask<>nil then //在这个事件下,lflowtask是空的
begin
// ldeptID:=datasetbroker1.dataset.fieldbyname('ZXBM').asstring; //取得字段内容,为执行部门id串
lflowtask.ProcUnit.ID :='QB_ZX';
lFlowTask.Executors.Clear;
//OrgChildren(OrgKey('lDept', 'JL', '') , '', False, False)
lexecrange:='OrgChildren(OrgKey('''+datasetbroker1.dataset.fieldbyname('ZXBM').asstring+''',''YHBMZH'',''''),'''',false,false)';
lFlowTask.AllowExecutorRange:=lexecrange;
lFlowTask.ExecutorRange:=lexecrange;
end;
end; |