我想在工作流程获得批准后将我的文件移动到其他目录上,正在使用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 < bpm_package.children.length; i++)
{
bpm_package.children[i].move(dest);
}</activiti:expression>
</activiti:field>
</activiti:taskListener>
我在alfresco上收到此错误:
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移动我的文档?!!
答案 0 :(得分: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 < bpm_package.children.length; i++)
{
bpm_package.children[i].move(dest);
}
</activiti:string>
</activiti:field>
答案 1 :(得分: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 < bpm_package.children.length; i++)
{
bpm_package.children[i].move(dest);
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
答案 2 :(得分: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 < 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 < bpm_package.children.length; i++)
{
bpm_package.children[i].move(dest);
}
]]></activiti:string>
</activiti:field>
</activiti:taskListener>