cancel
Showing results for 
Search instead for 
Did you mean: 

recover the re-assigned user

alessioa_
Champ in-the-making
Champ in-the-making
Hi to all the folks,
I need to recover the properties of the user when i re-assigned a task (in the Advanced WorkFolw AdHoc Task), it's possible to get this information?
I have a rule that start a workflow:
var workFlow = actions.create("start-workflow");
workFlow.parameters.workflowName = "jbpm$wf:my_adhoc";
workFlow.parameters["bpm:workflowDescription"] = newFile.name;
workFlow.parameters["bpm:assignee"] = person;
workFlow.parameters["wf:notifyMe"] = false;
workFlow.execute(newFile);

So, imaging the person who kicked off the rule is an administrator the bpm_assigne is, during the workflow, valued with the administrator properties.
But if the administrator decide to re-assign this task to another user and i want to send an e-mail to this user, for example,  for warning it that there is a task it must develop, how can do it?
Have had someone the some problem and able to give me an hint?
Thank you very much,
Best regards
Alessio A.
5 REPLIES 5

davidc
Star Contributor
Star Contributor
Hi Alessio,

This is an interesting feature, so I played around with adhoc_processdefinition.xml and came up with the following addition:

   
  <task name="wf:adhocTask" swimlane="assignee">
       …
     <event type="task-assign">
             <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <script>
                   if (taskInstance.previousActorId != null &amp;&amp; (taskInstance.previousActorId != taskInstance.actorId))
                   {
                      // retrieve person objects identified by task actorId and previousActorId
                      // TODO: provide built-in task properties that do the following search for you
                      var previousActor = search.luceneSearch("@cm\\:userName:\"" + taskInstance.previousActorId + "\"");
                      var actor = search.luceneSearch("@cm\\:userName:\"" + taskInstance.actorId + "\"");
                     
                      // send e-mail
                      var mail = actions.create("mail");
                      mail.parameters.to = actor.properties["cm:email"];
                      mail.parameters.subject = "Re-assigned Adhoc Task " + bpm_workflowDescription;
                      mail.parameters.from = previousActor.properties["cm:email"];
                      mail.parameters.text = "Hey, I've assigned you my task. Regards " + previousActor.properties["cm:firstName"];
                      mail.execute(bpm_package);
                   }
                </script>
             </action>
          </event>
         
         ….
     </task>

I'm using a task event called 'task-assign' which is fired whenever the task  is first assigned to someone and when it's re-assigned to someone else.

Within this event, the variable called 'taskInstance' (a standard jBPM variable) is available.  This has attributes actorId and previousActorId.   I've used these to locate the respective Alfresco person objects.

Then I just send an e-mail in the usual way.

I will file an enhancement request to add variables for accessing the current task owner and previous task owner (as Alfresco person objects) without resorting to searching manually.

alessioa_
Champ in-the-making
Champ in-the-making
Hi davidc,
thank you very much for the hint and i'm happy my question was been useful for Alfresco enhancement.
I tried your solution but receive a strange error, this is my task-assign:
<event type="task-assign">
  <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
    <script>
     logger.log("task attualmente assegnato a: "+taskInstance.previousActorId);
     logger.log("task ri-assegnato a: "+taskInstance.actorId);
     if (taskInstance.previousActorId != null &amp;&amp; (taskInstance.previousActorId != taskInstance.actorId)){
        var docname = bpm_package.children[0].properties["name"].substring(0, bpm_package.children[0].properties["name"].lastIndexOf('.'));
        var previousActor = search.luceneSearch("@cm\\:userName:\"" + taskInstance.previousActorId + "\"");
        var actor = search.luceneSearch("@cm\\:userName:\"" + taskInstance.actorId + "\"");
         logger.log("previousActor: " + taskInstance.previousActorId);
         logger.log("actor: " + taskInstance.actorId);
        var mail = actions.create("mail");
        mail.parameters.to = actor.properties["cm:email"];
        mail.parameters.subject = docname;
        mail.parameters.from = previousActor.properties["cm:email"];
        mail.parameters.text = "Ti è stata assegnata l'offerta in oggetto da completare. Saluti " + previousActor.properties["cm:firstName"];
        mail.execute(bpm_package);
    }
    </script>
  </action>
</event>

And i received this error:

09:39:59,675 ERROR [org.jbpm.graph.def.GraphElement] action threw exception: Failed to execute supplied script: ReferenceError: "search" is not defined. (AlfrescoScript#1)
org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: ReferenceError: "search" is not defined. (AlfrescoScript#1)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:181)
   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:32)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:195)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61)
   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 $Proxy56.executeScriptString(Unknown Source)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.execute(AlfrescoJavaScript.java:116)
   at org.jbpm.graph.def.Action.execute(Action.java:123)
   at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
   at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212)
   at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:182)
   at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:166)
   at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<generated>)
   at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
   at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
   at org.jbpm.taskmgmt.def.Task$$EnhancerByCGLIB$$1dd20c96.fireEvent(<generated>)
   at org.jbpm.taskmgmt.exe.TaskInstance.setActorId(TaskInstance.java:289)
   at org.jbpm.taskmgmt.exe.TaskInstance.setActorId(TaskInstance.java:263)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.setTaskProperties(JBPMEngine.java:1348)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine$16.doInJbpm(JBPMEngine.java:860)
   at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:333)
   at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.updateTask(JBPMEngine.java:784)
   at org.alfresco.repo.workflow.WorkflowServiceImpl.updateTask(WorkflowServiceImpl.java:281)
   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:32)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:210)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:156)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61)
   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 $Proxy24.updateTask(Unknown Source)
   at org.alfresco.web.bean.workflow.ReassignTaskDialog.finishImpl(ReassignTaskDialog.java:79)
   at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:89)
   at org.alfresco.web.bean.dialog.DialogManager.finish(DialogManager.java:311)
   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.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
   at javax.faces.component.UICommand.broadcast(UICommand.java:106)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
   at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:105)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)
Caused by: org.alfresco.error.AlfrescoRuntimeException: ReferenceError: "search" is not defined. (AlfrescoScript#1)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptImpl(RhinoScriptService.java:256)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:177)
   … 93 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "search" is not defined. (AlfrescoScript#1)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3226)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3216)
   at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3289)
   at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1567)
   at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3161)
   at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)
   at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
   at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160)
   at org.mozilla.javascript.Context.evaluateReader(Context.java:1163)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptImpl(RhinoScriptService.java:244)
   … 94 more
09:39:59,800 ERROR [org.alfresco.web.ui.common.Utils] Unable to reassign the task due to system error:
org.alfresco.service.cmr.workflow.WorkflowException: Failed to update workflow task 'jbpm$330'
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.updateTask(JBPMEngine.java:875)
   at org.alfresco.repo.workflow.WorkflowServiceImpl.updateTask(WorkflowServiceImpl.java:281)
   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:32)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:210)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:156)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61)
   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 $Proxy24.updateTask(Unknown Source)
   at org.alfresco.web.bean.workflow.ReassignTaskDialog.finishImpl(ReassignTaskDialog.java:79)
   at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:89)
   at org.alfresco.web.bean.dialog.DialogManager.finish(DialogManager.java:311)
   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.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
   at javax.faces.component.UICommand.broadcast(UICommand.java:106)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
   at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:105)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)
Caused by: org.jbpm.graph.def.DelegationException
   at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:352)
   at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<generated>)
   at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
   at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
   at org.jbpm.graph.def.ProcessDefinition$$EnhancerByCGLIB$$bbcf4181.raiseException(<generated>)
   at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:346)
   at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<generated>)
   at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
   at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
   at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$be1488cb.raiseException(<generated>)
   at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:346)
   at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:249)
   at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212)
   at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:182)
   at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:166)
   at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<generated>)
   at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
   at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
   at org.jbpm.taskmgmt.def.Task$$EnhancerByCGLIB$$1dd20c96.fireEvent(<generated>)
   at org.jbpm.taskmgmt.exe.TaskInstance.setActorId(TaskInstance.java:289)
   at org.jbpm.taskmgmt.exe.TaskInstance.setActorId(TaskInstance.java:263)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.setTaskProperties(JBPMEngine.java:1348)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine$16.doInJbpm(JBPMEngine.java:860)
   at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:333)
   at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.updateTask(JBPMEngine.java:784)
   … 54 more
Caused by: org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: ReferenceError: "search" is not defined. (AlfrescoScript#1)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:181)
   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:32)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:195)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61)
   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 $Proxy56.executeScriptString(Unknown Source)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.execute(AlfrescoJavaScript.java:116)
   at org.jbpm.graph.def.Action.execute(Action.java:123)
   at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
   … 70 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: ReferenceError: "search" is not defined. (AlfrescoScript#1)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptImpl(RhinoScriptService.java:256)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:177)
   … 93 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "search" is not defined. (AlfrescoScript#1)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3226)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3216)
   at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3289)
   at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1567)
   at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3161)
   at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)
   at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
   at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160)
   at org.mozilla.javascript.Context.evaluateReader(Context.java:1163)
   at org.alfresco.repo.jscript.RhinoScriptService.executeScriptImpl(RhinoScriptService.java:244)
   … 94 more

It's seems to search object is not defined… this is the first time i use the  search API but it's too strange it is an hack so where is my lack of knowledge about it?
Thanks again,
best regards
Alessio A.

davidc
Star Contributor
Star Contributor
It's possible the 'search' object in workflow feature did not make into to community 1.4 final.

If you take a look at http://wiki.alfresco.com/wiki/JavaScript_API, you'll see the complete api for javascript, including search.  The search syntax used in the sample is described at http://wiki.alfresco.com/wiki/Search#Lucene.

alessioa_
Champ in-the-making
Champ in-the-making
Hi davidc,
the search object in a simple js file works well, so the problem is into the workflow…
What do you mean exactly when say :"'search' object in workflow feature did not make into to community 1.4 final"?
This feature is only for small business and enterprise version? If so, it's only an oversight or a commercial choice?
Thanks for attention
Alessio A.

davidc
Star Contributor
Star Contributor
As you note, search is available in general scripts, but it was missing in workflow scripts (a bug).  The bug fix did not make it into 1.4 community final (an oversight).