0

当工作流被批准时,我想将我的文件移动到其他目录,正在使用 activiti,我插入以下代码

<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
      <activiti:field name="script">
        <activiti:expression>if(task.getVariableLocal('scwf_approveRejectOutcome') == 'Approve') {

    var dest = bpm_context.childByNamePath("nv");
    for (var i = 0; i &lt; bpm_package.children.length; i++)
    {
        bpm_package.children[i].move(dest);
    }</activiti:expression>
      </activiti:field>
</activiti:taskListener>

我在露天得到这个错误:

org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Incompatible type set on field declaration 'script' for class org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript. Declared value has type org.activiti.engine.impl.el.JuelExpression, while expecting org.dom4j.Element

我怎样才能用activiti移动我的文档?!!

4

3 回答 3

2

它应该是

<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
  <activiti:field name="script">
    <activiti:string>
      if(task.getVariableLocal('scwf_approveRejectOutcome') == 'Approve') {

      var dest = bpm_context.childByNamePath("nv");
      for (var i = 0; i &lt; bpm_package.children.length; i++)
      {
        bpm_package.children[i].move(dest);
      }
    </activiti:string>
  </activiti:field>

于 2013-09-26T09:20:28.430 回答
1

您使用了错误的标签来包装脚本内容。正如错误消息所暗示的,它无法将类型值分配给任务侦听org.activiti.engine.impl.el.JuelExpression器的script字段。

使用activity:string而不是activity:expression应该按预期工作:

<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
      <activiti:field name="script">
        <activiti:string>
          if(task.getVariableLocal('scwf_approveRejectOutcome') == 'Approve') {

          var dest = bpm_context.childByNamePath("nv");
          for (var i = 0; i &lt; bpm_package.children.length; i++)
          {
            bpm_package.children[i].move(dest);
          }
        </activiti:string>
      </activiti:field>
</activiti:taskListener>
于 2013-09-24T11:23:41.403 回答
0

试试这个,将代码包装<activiti:string><![CDATA[ your code ]]>

<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
      <activiti:field name="script">
        <activiti:string><![CDATA[
          if(task.getVariableLocal('scwf_approveRejectOutcome') == Approve') {
          var dest = bpm_context.childByNamePath("nv");
          for (var i = 0; i &lt; bpm_package.children.length; i++)
          {
            bpm_package.children[i].move(dest);
          }
       ]]> </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('scwf_approveRejectOutcome') == 'Approve') {
              var dest = bpm_context.childByNamePath("nv");
              for (var i = 0; i &lt; bpm_package.children.length; i++)
              {
                bpm_package.children[i].move(dest);
              }
    ]]></activiti:string>
  </activiti:field>
</activiti:taskListener>
于 2015-06-19T11:08:31.317 回答