【问题标题】:How can I get the id of the workflow instance in workflow form?如何以工作流形式获取工作流实例的 ID?
【发布时间】:2017-03-13 14:36:45
【问题描述】:

我有 FreeMarker 模板,这是用于显示有关业务流程的一些数据的自定义字段。

比方说,userdetails.ftl:

<@link href="${url.context}/res/components/workflow/workflow-form.css" group="workflow"/>
<#include "/org/alfresco/components/form/controls/common/utils.inc.ftl" />

<div class="form-field">
   <div id="...">
      <table id="..." class="yui-dt">
         <tr>
            <th class="yui-dt-liner">Field_1</th>
            <th class="yui-dt-liner">Field_2</th>
            <th class="yui-dt-liner">Field_3</th>
            <th class="yui-dt-liner">Field_4</th>
            ...
            <th class="yui-dt-liner">Field_N</th>
         </tr>
         ...
      </table>
   </div>
</div>

<script>

// Here I want to call REST back-end and parse the JSON response

</script>

share-config-custom.xml的相关部分:

<config evaluator="task-type" condition="mswf:reviewTask">
  <forms>
     <form>
        <field-visibility>
           <show id="mswf:userDetails" />
        </field-visibility>
        <appearance>
           <set id="userDetails" appearance="title" label="User Details" />
            <field id="mswf:userDetails" set="userDetails" label="User Details">
                <control template="/org/alfresco/components/form/controls/workflow/userdetails.ftl" />
            </field>
           <field id="transitions" set="response" />
        </appearance>
     </form>
  </forms>
</config>

此模板包含一个表格,我想在其中显示将参与业务流程的用户列表(谁被分配)。

Inside tags &lt;script&gt;&lt;/script&gt; 我想调用一个嵌入式 Alfresco WebScript(或我自己的 - 在这种情况下并不重要),它会返回有关业务流程的所有必要信息:

http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/processes/26205/variables

,其中26205 == id 的流程实例。

我得到以下信息:

{
   "list":{
      "pagination":{
         "count":36,
         "hasMoreItems":false,
         "totalItems":36,
         "skipCount":0,
         "maxItems":100
      },
      "entries":[
         {
            "entry":{
               "name":"bpm_packageActionGroup",
               "type":"d:text"
            }
         },
         {
            "entry":{
               "name":"mswf_approveCount",
               "type":"d:double",
               "value":0.0
            }
         },
         {
            "entry":{
               "name":"bpm_reassignable",
               "type":"d:boolean",
               "value":true
            }
         },
         {
            "entry":{
               "name":"bpm_priority",
               "type":"d:int",
               "value":2
            }
         },
         {
            "entry":{
               "name":"initiator",
               "type":"d:noderef",
               "value":"admin"
            }
         },
         {
            "entry":{
               "name":"mswf_actualRejectPercent",
               "type":"d:double",
               "value":0.0
            }
         },
         {
            "entry":{
               "name":"bpm_percentComplete",
               "type":"d:int",
               "value":0
            }
         },
         {
            "entry":{
               "name":"bpm_sendEMailNotifications",
               "type":"d:boolean",
               "value":false
            }
         },
         {
            "entry":{
               "name":"mswf_reviewOutcome",
               "type":"d:text",
               "value":"Reject"
            }
         },
         {
            "entry":{
               "name":"bpm_workflowPriority",
               "type":"d:int",
               "value":1
            }
         },
         {
            "entry":{
               "name":"bpm_hiddenTransitions",
               "type":"d:text"
            }
         },
         {
            "entry":{
               "name":"workflowinstanceid",
               "type":"d:text",
               "value":"activiti$26205"
            }
         },
         {
            "entry":{
               "name":"taskFormKey",
               "type":"d:text",
               "value":"mswf:activitiReviewTask"
            }
         },
         {
            "entry":{
               "name":"bpm_workflowDueDate",
               "type":"d:date",
               "value":"2017-03-12T20:00:00.000+0000"
            }
         },
         {
            "entry":{
               "name":"mswf_requiredPercent",
               "type":"d:double",
               "value":100.0
            }
         },
         {
            "entry":{
               "name":"mswf_reviewerCount",
               "type":"d:double",
               "value":2.0
            }
         },
         {
            "entry":{
               "name":"bpm_package",
               "type":"bpm:workflowPackage",
               "value":"workspace://SpacesStore/72086323-6c65-46f9-a1ad-8877630a6b40"
            }
         },
         {
            "entry":{
               "name":"mswf_actualPercent",
               "type":"d:double",
               "value":0.0
            }
         },
         {
            "entry":{
               "name":"nrOfActiveInstances",
               "type":"d:int",
               "value":2
            }
         },
         {
            "entry":{
               "name":"bpm_workflowDescription",
               "type":"d:text",
               "value":"message..."
            }
         },
         {
            "entry":{
               "name":"mswf_rejectCount",
               "type":"d:double",
               "value":0.0
            }
         },
         {
            "entry":{
               "name":"bpm_packageItemActionGroup",
               "type":"d:text",
               "value":"edit_package_item_actions"
            }
         },
         {
            "entry":{
               "name":"companyhome",
               "type":"d:noderef",
               "value":"workspace://SpacesStore/64f9f3c3-9227-425d-b336-bd255ab94c83"
            }
         },
         {
            "entry":{
               "name":"_startTaskCompleted",
               "type":"d:datetime",
               "value":"2017-03-13T07:03:12.612+0000"
            }
         },
         {
            "entry":{
               "name":"bpm_assignees",
               "type":"cm:person",
               "value":[
                  "first",
                  "second"
               ]
            }
         },
         {
            "entry":{
               "name":"loopCounter",
               "type":"d:int",
               "value":1
            }
         },
         {
            "entry":{
               "name":"bpm_description",
               "type":"d:text",
               "value":"message... "
            }
         },
         {
            "entry":{
               "name":"nrOfInstances",
               "type":"d:int",
               "value":2
            }
         },
         {
            "entry":{
               "name":"initiatorhome",
               "type":"d:noderef",
               "value":"workspace://SpacesStore/64f9f3c3-9227-425d-b336-bd255ab94c83"
            }
         },
         {
            "entry":{
               "name":"bpm_outcomePropertyName",
               "type":"d:qname",
               "value":"mswf:reviewOutcome"
            }
         },
         {
            "entry":{
               "name":"cm_name",
               "type":"d:text",
               "value":"Task"
            }
         },
         {
            "entry":{
               "name":"bpm_status",
               "type":"d:text",
               "value":"Not Yet Started"
            }
         },
         {
            "entry":{
               "name":"cancelled",
               "type":"d:boolean",
               "value":false
            }
         },
         {
            "entry":{
               "name":"reviewAssignee",
               "type":"d:noderef",
               "value":"second"
            }
         },
         {
            "entry":{
               "name":"mswf_requiredApprovePercent",
               "type":"d:int",
               "value":100
            }
         },
         {
            "entry":{
               "name":"nrOfCompletedInstances",
               "type":"d:int",
               "value":0
            }
         }
      ]
   }
}

除了我对这部分感兴趣的所有其他内容:

"entry":{
   "name":"bpm_assignees",
   "type":"cm:person",
   "value":[
      "first",
      "second"
   ]
}

这是将参与业务流程的用户列表(在此特定实例中)。

要获取所有这些信息,我需要知道流程实例的 ID(在本例中为 26205)。

我可以在我的userdetails.ftl 模板中确定这个标识符吗?

【问题讨论】:

  • {"entry":{"dueAt":"2017-03-12T20:00:00.000+0000","‌​processDefinitionId"‌​:"contractsApproval:‌​116:26804", "processI‌​d":"26938","name":"R‌​eview Task",...} 正如您所说,您可以从此处获取您的进程 ID。通过这个 ID,你调用这个 url localhost:8080/alfresco/api/-default-/public/workflow‌​/versions/1/processe‌​s/26938/variables 所以。如果你从 url 获取 id 就可以了。
  • 如果您想获取特定用户的工作流实例 ID 和任务 ID,那么也可以使用 rest api。 freemarker api docs.alfresco.com/4.0/references/API-FreeMarker-Workflow.html 或者你也可以使用 java 类来获取它。

标签: alfresco activiti alfresco-webscripts


【解决方案1】:

工作流 ID 确实是您的工作流中可用的变量之一,我建议您使用隐藏的表单控件 hidden.ftl 将其添加到您的表单中,然后从您的 JS sn-p 中使用 dom 访问隐藏的按 ID/名称输入并在您认为合适的逻辑中使用它!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-22
    • 1970-01-01
    • 2020-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多