Hi. I'd like to understand if it's possible to switch to admin user during a workflow dinamically. I'm sure that admin can perform moving or deleting action over all space. I'd like to define something like:step 1: user A start a workflow in his home space;step 2: admin user (inside the workflow) moves the document to a specific space where the user B can access;step 3: user B perform a task;step 4: admin moves the document to original position.
I try to implement the movement but I have some problem to store the initial position of the document(package). This is the code:
…
<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? Can anybody help me?Thanks for any advice