AnsweredAssumed Answered

workflow advances variables always undefined

Question asked by haroldvera on Apr 12, 2010
Latest reply on Apr 14, 2010 by hyperation
i have this decision in my workflow,

<decision name="tiene email">
        <event type="node-enter">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
           <variable name="bpm_package" access="read" />   
           <expression>
              &lt;import resource="/Company Home/Data Dictionary/Scripts/my_wf_logic.js"&gt;
              dnswf_tieneMail="no";
              tieneEmail(bpm_package);
              executionContext.setVariable("dnswf_tieneMail",dnswf_tieneMail);
           </expression>
           <variable name="dnswf_tieneMail" access="write"/>
          </script>
         </action>
        </event>

      <transition to="espera notificacion" name="si">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                 <variable name="timeRepresentante" access="write"/>
                 <expression>
                     timeRepresentante='2 business days';
                 </expression>
            </script>
          </action>
          <condition>#{dnswf_tieneMail=="si"}</condition>
      </transition>
      <transition to="imprime y envia carta" name="no">
         <condition>#{dnswf_tieneMail=="no"}</condition>
      </transition>
      
   </decision>

my_wf_logic.js
————————————
var tieneEmail = function(bpm_package){
   for (var a = 0; a < bpm_package.children.length; a++)
      {
        if(bpm_package.children[a].properties["cm:categories"]!=undefined && bpm_package.children[a].properties["cm:categories"]!=null){
           for (var b = 0; b < bpm_package.children[a].properties["cm:categories"].length; b++){
              if (bpm_package.children[a].properties["cm:categories"].properties["cm:name"]=="cartas representante"){
              if((bpm_package.children[a].properties["mtt:emailCiudadano"]!=undefined && bpm_package.children[a].properties["mtt:emailCiudadano"]!=null)){
                                       dnswf_tieneMail="si";
                                  }
              }
           }
                  }
           }
}


if I debug the javascript code, the variable takes the value dnsw_tieneEmail "yes" but the value is undefined in the decision. I appreciate any assistance.

Outcomes