AnsweredAssumed Answered

Transition cond. not working with variable in action class

Question asked by sasi.kumar on Nov 7, 2008
Latest reply on Nov 28, 2008 by sasi.kumar
Hi,
We have encountered some problem when we declare a variable in the script,when we are using action class in the decision node.Below  exception raised when we perform the transition.
We tried using variable declaration without using action class. Here, the transition worked fine. But, if we assign a value to the variable from action class, the transition condition is not working and always executes the first transition. Here no exception raised.

Kindly provide the solution for using variable in action class and with transition condition.

<decision name="isApproved">              
   <event type="node-enter">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
        <[b]variable[/b] name="wfl_checkStatus" access="read, write"/>
             <expression>                      
      wfl_checkStatus  = bpm_package.children[0].properties["ck:Status"];               logger.log("Status "+wfl_checkStatus);                  
                       </expression>
                </script>
             </action>
      </event>  
        <transition name="approve" to="published" >          
          <condition>#{wfl_checkStatus == "Waiting for Validation"}</condition>
        </transition>
       
        <transition name="Re-edit" to="editing" >
           <condition>#{wfl_checkStatus != "Waiting for Validation"}</condition>
        </transition>
</decision>


Caused by: org.alfresco.scripts.ScriptException: Failed to execute supplied scri
pt: ReferenceError: "bpm_package" is not defined. (AlfrescoScript#1)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeString(RhinoScr
iptProcessor.java:187)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScriptString(Scr
iptServiceImpl.java:279)
        … 112 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: ReferenceError: "bpm_pac
kage" is not defined. (AlfrescoScript#1)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(Rhin
oScriptProcessor.java:403)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeString(RhinoScr
iptProcessor.java:183)
        … 113 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "bpm_package" is no
t defined. (AlfrescoScript#1)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.jav
a:3350)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.jav
a:3340)
        at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java
:3413)
        at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)
        at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:331
4)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.j
ava:162)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
93)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:283
4)
        at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.j
ava:173)
        at org.mozilla.javascript.Context.evaluateString(Context.java:1196)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(Rhin
oScriptProcessor.java:396)
        … 114 more

Outcomes