0 Replies Latest reply on Aug 17, 2012 11:11 AM by efish11

    unable to get workflow id in ecma script

    efish11

      I am using the following ecma script in a OR split

       

      function check() {

       

       

         log.info("##########IN CHECK FUNCTION###########");

        

         var path=workItem.getWorkflow().getId() + "/metaData"

         var node=workflowSession.getSession().getItem(path);

         if (node.hasProperty("multipleapprovers")){

       

                   if(node.getProperty("multipleapprovers").getString() == "NOMOREREVIEWERS"){

                       return true;

                   }else{

                       return false;

                   }

            }

      }

       

       

      but i am seeing the following error in logs, I assumed workItem reference was provided to ECMA scripts

       

      Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "workItem" is not defined. (/etc/workflow/scripts/script2.ecma#5)

                at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)

                at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)

                at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3413)

                at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)

                at org.mozilla.javascript.gen.c14._c1(/etc/workflow/scripts/script2.ecma:5)

                at org.mozilla.javascript.gen.c14.call(/etc/workflow/scripts/script2.ecma)

                at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)

                at org.mozilla.javascript.gen.c14._c0(/etc/workflow/scripts/script2.ecma:20)

                at org.mozilla.javascript.gen.c14.call(/etc/workflow/scripts/script2.ecma)

                at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)

                at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)

                at org.mozilla.javascript.gen.c14.call(/etc/workflow/scripts/script2.ecma)

                at org.mozilla.javascript.gen.c14.exec(/etc/workflow/scripts/script2.ecma)

                at org.mozilla.javascript.Context.evaluateReader(Context.java:1227)

                at org.apache.sling.scripting.javascript.internal.RhinoJavaScriptEngine.eval(RhinoJavaScript Engine.java:114)

                at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:358)

       

       

      Any suggestions/pointers are appreciated

       

      Environment

       

      CQ 5.5, windows