2016-01-26 31 views
3

我需要從我的開始表單上的文本字段設置一個值,然後將這些信息放在其他幾個任務上。爲此,我正在使用一個方面並嘗試將數據發送到執行變量,然後將其拉下。Activiti工作流程:從StartTask設置某個方面的值

問題是我無法將值從開始表單發送到執行變量。就像現在一樣,Share只會說工作流程無法啓動。

我使用的是Alfresco 4.2.f社區版。

啓動事件在BPMN定義如下:

<startEvent id="start" name="Start Delivery Ticket Workflow" activiti:initiator="initiatorUserName" activiti:formKey="deliveryTicketWorkflow:start"> 
    <documentation>Project Manager initiates workflow. A customer purchase order is provided, along with the specific line items for the delivery ticket.</documentation> 
    <extensionElements> 
    <activiti:executionListener class="org.alfresco.repo.workflow.activiti.listener.ExecutionListener" event="start"> 
     <activiti:field name="script"> 
     <activiti:string><![CDATA[ 
      execution.setVariable('deliveryTicketWorkflow_requestdetailstext', task.getVariable('deliveryTicketWorkflow_requestdetailstext'));; 
     ]]></activiti:string> 
     </activiti:field> 
    </activiti:executionListener> 
    </extensionElements> 
</startEvent> 

我的模型的相關部分:

<type name="deliveryTicketWorkflow:start"> 
    <parent>bpm:startTask</parent> 
    <properties /> 
    <associations /> 
    <overrides /> 
    <mandatory-aspects> 
    <aspect>deliveryTicketWorkflow:requestdetails</aspect> 
    </mandatory-aspects> 
</type> 
[...] 
<aspect name="deliveryTicketWorkflow:requestdetails"> 
    <properties> 
    <property name="deliveryTicketWorkflow:requestdetailstext"> 
     <title>Specific Details</title> 
     <type>d:text</type> 
     <mandatory>true</mandatory> 
     <multiple>false</multiple> 
    </property> 
    </properties> 
</aspect> 

在配置:

<config condition="deliveryTicketWorkflow:start" evaluator="task-type"> 
    <forms> 
     <form> 
      <field-visibility> 
       <show id="packageItems"/> 
       <show id="deliveryTicketWorkflow:requestdetailstext"/> 
       <show id="transitions"/> 
      </field-visibility> 
      <appearance> 
       <set appearance="title" label-id="Prepare Delivery Ticket" id="info"/> 
       <field set="info" id="packageItems"/> 
       <field set="info" label-id="Request Details" id="deliveryTicketWorkflow:requestdetailstext"> 
        <control template="/org/alfresco/components/form/controls/info.ftl"/> 
       </field> 
       <set id="response"/> 
       <field set="response" id="transitions"/> 
      </appearance> 
     </form> 
    </forms> 
</config> 
[...] 
<config condition="activiti$deliveryTicketWorkflow" evaluator="string-compare"> 
    <forms> 
     <form> 
      <field-visibility> 
       <show id="bpm:workflowPriority"/> 
       <show id="packageItems"/> 
       <show id="deliveryTicketWorkflow:requestdetails"/> 
       <show id="transitions"/> 
       <show id="deliveryTicketWorkflow:approveRejectOutcome"/> 
      </field-visibility> 
      <appearance> 
       <set appearance="title" label-id="Request Delivery Ticket" id="info"/> 
       <field set="info" label-id="workflow.field.priority" id="bpm:workflowPriority"> 
        <control template="/org/alfresco/components/form/controls/workflow/priority.ftl"/> 
       </field> 
       <field set="info" id="packageItems"/> 
       <field set="info" label-id="Request Details" id="deliveryTicketWorkflow:requestdetails"> 
        <control template="/org/alfresco/components/form/controls/textarea.ftl"/> 
       </field> 
       <set id="response"/> 
       <field set="response" id="approveRejectOutcome"> 
        <control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl"/> 
       </field> 
       <field set="response" id="transitions"/> 
      </appearance> 
     </form> 
    </forms> 
</config> 

我有在這裏看到至少有一個類似的問題,但答案是要使用任務監聽器作爲開始表單。我並不確定它是如何工作的,因爲它看起來像一個啓動任務不是一個「真正的」任務,只能使用ExecutionListeners。差異應該很小,但似乎任何對啓動任務中「任務」的引用都會導致失敗或根本沒有任何影響。因爲我不能使用task.getVariableLocal()來獲取值,我沒有看到要給execution.setVariable()作爲值的內容。

回答

3

根據我的經驗,啓動任務中的方面和屬性的所有值都會自動複製到executionContext中,並且已經可用於將來的任務。

嘗試刪除您的BPMN中的executionlistener,你不應該需要。然後嘗試在後續任務中創建一個starttasklistener,將您的execeutioncontext中的值複製到此任務中。它應該工作正常。

獲得了var從您的後續任務的執行上下文迴應該像這樣工作:

<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> 
    <activiti:field name="language" stringValue="groovy"/
    <activiti:field name="script"> 
    <activiti:string><![CDATA[ 
    System.out.println(execution.getVariable("deliveryTicketWorkflow_requestdetailstext"));   
    if (execution.getVariable("deliveryTicketWorkflow_requestdetailstext") != null){ 
    task.setVariableLocal('deliveryTicketWorkflow_requestdetailstext', execution.getVariable("deliveryTicketWorkflow_requestdetailstext")); 
    }]]> 
    </activiti:string> 
</activiti:field> 
</activiti:taskListener> 
+0

像這樣在需要閱讀它的任務中?因爲這不適合我。 <![< CDATA [ ] if(typeof deliveryTicketWorkflow_requestdetailstext!='undefined'){task_setVariableLocal('deliveryTicketWorkflow_requestdetailstext',deliveryTicketWorkflow_requestdetailstext); };]]> ' –

+0

澄清:當我移除執行偵聽器並在接下來有上述任務偵聽器任務,但消息仍然不會從起始表單移動到第二個表單 –

+0

您應該從執行上下文對象(execution.getVariable(「deliveryTicketWorkflow_requestdetailstext」))中獲取值。我已經更新了我的回答 –

0

這是一個長鏡頭,但在您的共享形式,您的自定義字段使用信息控制:

我相信你需要那裏是一個普通場那裏,信息字段顯示文本,AFAIK,它不包含輸入字段,並且不會向工作流程開始發送任何內容。

+0

你的建議是正確的信息formcontrol不支持數據修改,而不會提交任何數據(甚至不是一個默認數據或預先輸入的值),並且由於啓動任務的模型具有'deliveryTicketWorkflow:requestdetails'作爲強制性方面,它具有'deliveryTicketWorkflow:requestdetailstext'作爲強制性屬性,導致工作流無法啓動,因爲它缺少一些強制性數據。但是,這並不能幫助OP將一些數據從啓動任務傳遞給其他任務...... –

+0

@MichaelKay:你能否啓動這個過程(即使你不能從稍後的一些啓動事件中獲取值其他任務)? –

+0

我目前無法啓動該過程。我在alfresco.log,alfrescotomcat-stderr.log或alfrescotomcat-stdout.log中看不到任何內容,詳細說明它失敗的原因。 –

相關問題