05-06-2007 11:17 AM
…
<task-node name="tsk1">
<task name="wf:task1" swimlane="initiator" />
<transition name="go" to="tsk2">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var origin = bpm_context.name;
var dest = companyhome.childByNamePath("Intranet/SharedSpace/");
for (var i = 0; i < bpm_package.children.length; i++)
{
bpm_package.children[i].move(dest);
}
</script>
</action>
</transition>
</task-node>
<task-node name="tsk2">
<task name="wf:task2" swimlane="assignee"/>
<transition name="finish" to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
for (var i = 0; i < bpm_package.children.length; i++)
{
bpm_package.children[i].move(origin);
}
</script>
</action>
</transition>
</task-node>
…
and this is the error (initial part):
17:12:46,556 ERROR [graph.def.GraphElement] action threw exception: Failed to execute supplied script: ReferenceError: "origin" is not defined. (AlfrescoScript#1)
org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: ReferenceError: "origin" is not defined. (AlfrescoScript#1)
at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:204)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy55.executeScriptString(Unknown Source)
at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.executeScript(AlfrescoJavaScript.java:157)
"origin" is not global? 05-11-2007 01:00 PM
"origin" is not global?
05-15-2007 08:43 AM
You need to pass your local script variable to the containing script context…
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
// some alfresco javascript
</expression>
<variable name="origin" access="write"/>
</script>
</action>
http://wiki.alfresco.com/wiki/WorkflowAdministration#Actions_.26_Scripting
…
<task-node name="tsk1">
<task name="wf:task1" swimlane="initiator" />
<transition name="go" to="tsk2">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
var origin = bpm_context.name;
var dest = companyhome.childByNamePath("Intranet/SharedSpace/");
for (var i = 0; i < bpm_package.children.length; i++)
{
bpm_package.children[i].move(dest);
}
</expression>
<variable name="origin" access="write"/>
</script>
</action>
</transition>
</task-node>
<task-node name="tsk2">
<task name="wf:task2" swimlane="assignee"/>
<transition name="finish" to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
for (var i = 0; i < bpm_package.children.length; i++)
{
bpm_package.children[i].move(origin);
}
</expression>
</script>
</action>
</transition>
</task-node>
…
and this is the error (initial part):
14:15:03,542 ERROR [graph.def.GraphElement] action threw exception: Failed to execute supplied script: Can't find method org.alfresco.repo.jscript.Node.move(boolean). (AlfrescoScript#1)
org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: Can't find method org.alfresco.repo.jscript.Node.move(boolean). (AlfrescoScript#1)
at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:235)
Second test:
…
<task-node name="tsk1">
<task name="wf:task1" swimlane="initiator" />
<transition name="go" to="tsk2">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
var origin = bpm_context.name;
var dest = companyhome.childByNamePath("Intranet/SharedSpace/");
for (var i = 0; i < bpm_package.children.length; i++)
{
bpm_package.children[i].move(dest);
}
</expression>
<variable name="origin" access="write"/>
</script>
</action>
</transition>
</task-node>
<task-node name="tsk2">
<task name="wf:task2" swimlane="assignee"/>
<transition name="finish" to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
for (var i = 0; i < bpm_package.children.length; i++)
{
bpm_package.children[i].move(origin);
}
</expression>
<variable name="origin" access="read"/>
</script>
</action>
</transition>
</task-node>
…
and this is the error (initial part):
14:30:10,891 ERROR [graph.def.GraphElement] action threw exception: Failed to execute supplied script: ReferenceError: "bpm_package" is not defined. (AlfrescoScript#1)
org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: ReferenceError: "bpm_package" is not defined. (AlfrescoScript#1)
at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:235)
Where is, where are the mistakes?Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.