Alfresco检查是否添加了文件 [英] Alfresco check for adding files

查看:88
本文介绍了Alfresco检查是否添加了文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个审批流程 在开始表单上,附加了文件和选定的执行程序(Package ItemsPeople selection). 然后创建一个任务分配给先前选择的执行者. 每个执行者都会看到分配给它的任务以及文件附件.

There is a review and approval workflow On the start forms are attached files and selected executors(Package Items and People selection). Then create a task is assigned to the previously selected executors. Each executor sees the task assigned to it, and file attachments.

我需要检查是否添加了文件.执行者尚未添加文件,但无法批准该任务. 我在任务创建taskListener event="create"时创建了计数器. 他计算发送给执行者的文件. 然后,我在完成任务taskListener event="complete"时创建了另一个计数器,该计数器还对文件进行计数. 然后我比较这两个计数器,如果它们相等 这意味着执行者不附加文件,并且看到错误. 但是此方法仅适用于批准任务的第一个执行者. 其余执行者可以在不添加文件的情​​况下批准任务.

I need to check for adding files. While the executor has not added a file it can not approve the task. I created the counter at the time of task creation taskListener event="create". He counts the files sent to the executor. Then I created another counter at the time of completion of the task taskListener event="complete", It also counts files. Then I compare these two counters and if they are equivalent It means that the executor does not attach files and he sees the error. But this method works only for the first executor who approved the task. The rest of the executors can already approve the task without adding files.

我不知道问题出在哪里.

I do not know what the problem is.

这是我实现它的代码:

<userTask id="userTask5" name="Revies" activiti:assignee="${zvernennya_reviewnachassignee.properties.userName}" activiti:formKey="zvernennya:reviewnach">
      <documentation>Review task</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[
        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;;    
        var count=0;
        for (var i = 0; i < bpm_package.children.length; i++) 
        { 
        count++;
        }
        execution.setVariable ('count', count);
]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[
        if(task.getVariableLocal('zvernennya_reviewnachtransitions') == 'Approve') {
        execution.setVariable('zvernennya_reviewnachapprovalcount', zvernennya_reviewnachapprovalcount + 1);
        }   
                           var count_new=0;
                           for (var i = 0; i < bpm_package.children.length; i++) 
                           {  
                           count_new++;
                           }
                           if (count==count_new) {    
                                var message = "\n\nAttach files!!\n";
                                 throw new Error(message + "\n");
                            }   
]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="zvernennya_executers" activiti:elementVariable="zvernennya_reviewnachassignee">
        <completionCondition>${zvernennya_reviewnachapprovalcount &gt;= zvernennya_reviewnachrequiredapprovalcount}</completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>

推荐答案

我认为您需要在第二个任务侦听器(完成")中重新初始化变量"count".像这样:

I think you need to re-initialize the variable "count" in the 2nd tasklistener ("complete"). like so:

var count = execution.getVariable ('count');
var count_new= bpm_package.children.length;
if (count==count_new) {    
   var message = "\n\nAttach files!!\n";
   throw new Error(message + "\n");
}  

这篇关于Alfresco检查是否添加了文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆