工作流程:为bpm:assignee设置默认值

时间:2016-02-22 18:56:08

标签: alfresco alfresco-share

当我开始我的工作流程时,我想要选择将其分配给某人。如果没有人被选中,我想默认将它分配给发起人。

如果不创建扩展bpm:assignee的新模型,是否可以这样做?如果没有,该扩展将如何完成?

我相信Jeff Potts的答案是相关的:https://stackoverflow.com/a/9418066/4542428

注意:我使用的是社区版4.2

编辑:Stefan的回答让我得到了答案的绝大部分,但似乎我在某种程度上错误地引用了关联的价值。背景:我从未使用过关联,这可能只是因为我无法理解它们与类型和方面的区别。

从我的模特:

<type name="deliveryTicketWorkflow:start">
      <parent>bpm:startTask</parent>
      <properties>      
      </properties>
      <associations />
      <overrides />
      <mandatory-aspects>
        <aspect>deliveryTicketWorkflow:pmAspect</aspect>
        <aspect>deliveryTicketWorkflow:requestDetailsAspect</aspect>
      </mandatory-aspects>
</type>
<aspect name="deliveryTicketWorkflow:pmAspect">
        <associations>
            <association name="deliveryTicketWorkflow:assignedPM">
                    <source>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>
        </associations>
    </aspect>

我的配置用作:

<config condition="activiti$deliveryTicketWorkflow" evaluator="string-compare">
        <forms>
            <form>
                <field-visibility>
...
                    <show id="deliveryTicketWorkflow:assignedPM" />
...
                </field-visibility>
                <appearance>
...
                    <field id="deliveryTicketWorkflow:assignedPM" label-id="Project Manager" />
...
               </appearance>
            </form>
        </forms>
    </config>

我的deliveryTicketworkflow配置:start是完全相同的。这成功地显示了人物选择器,而没有强制要求,正好像Stefan所说的那样100%。

在我的bpmn工作流定义中,我将这些片段放在启动事件的执行监听器中:

          if(!execution.getVariable("deliveryTicketWorkflow_assignedPM")){
            execution.setVariable("deliveryTicketWorkflow_assignedPM", initiator);
          }
...
         deliveryTicket.properties["dtdlm:projectManager"] = execution.getVariable("deliveryTicketWorkflow_assignedPM").properties.firstName + " " + execution.getVariable("deliveryTicketWorkflow_assignedPM").properties.lastName;

当工作流程运行并且我选择某人作为PM时,该最后一行(抓取PM的名字和姓氏)返回未定义的值为&#34; deliveryTicketWorkflow_assignedPM&#34;。当它保持空白时,一切都在游泳,但工作流描述的常规信息部分仍然将项目管理器列为(无)。

1 个答案:

答案 0 :(得分:4)

正如杰夫所描述的,你确实可以自定义人员选择器,但它需要相当多的编码工作。

或者,您可以使用工作流执行顺序器来启动事件,并使用它将bpm_assignee变量设置为启动器,以防它在表单上为空:

向你添加监听器bpmn20:

 <activiti:executionListener event="start" class="com.mycomp.Executionlistener"></activiti:executionListener>

在您的第一个usertask中,在工作流程开始表单中定义关联属性的受让人。

 <userTask id="firsttask" name="firsttask" activiti:assignee="${mymodel.myassoc.properties.userName}" >

同时将此关联添加到您的启动任务内容模型。

com.mycomp.Executionlistener中的代码如下所示:

public void notify(DelegateExecution execution) throws Exception {
   if (execution.getVariable("mymodel_myassoc") == null ){

        ActivitiScriptNode userScriptNode= (ActivitiScriptNode) execution.getVariable("initiator");
        execution.setVariable("mymodel_myassoc",userScriptNode);
   }
 }
相关问题