Processes with 2 core for each not working

book

Article ID: 222764

calendar_today

Updated On:

Products

Clarity PPM SaaS

Issue/Introduction

Getting an error when running process with GEL scripts using columnStep in 15.9.3

STEPS TO REPRODUCE: 
1. Create basic process with GEL script as below
Note: update project codes in the GEL script to match for the environment you are running against.
<gel:script xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:core="jelly:core" 
xmlns:file="jelly:com.niku.union.gel.FileTagLibrary" 
xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary" 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:sql="jelly:sql" xmlns:util="jelly:util" 
xmlns:xog="http://www.niku.com/xog" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- ********************************************************************* -->
  <!--             Database Section                               -->
  <!-- ********************************************************************* -->
  <gel:setDataSource dbId="niku"/>
  <!-- <sql:query var="bpm">
 select c.user_name from bpm_run_processes b,cmn_sec_users c where c.id = b.created_by and b.id =${gel_processInstanceId}
    </sql:query><core:forEach indexVar="i" items="${bpm.rowsByIndex}" trim="false" var="row"><core:set var="username">${row[0]}</core:set></core:forEach> -->
 
      <!-- ********************************************************************* -->
      <!--                            Fetching Data                      -->
      <!-- ********************************************************************* -->


        <sql:query escapeText="false" var="result">
  SELECT 
      inv.code inv_code,
   inv.name inv_name
   FROM INV_INVESTMENTS INV 
   where inv.code in ('XYZ','XYZ2')

          </sql:query>
        
         <core:forEach indexVar="i" items="${result.rowsByIndex}" trim="false" var="col">
          <core:forEach indexVar="j" items="${result.columnNames}" step="${columnStep}" var="row">
          <core:set encode="0" var="project_code">${col[0]}</core:set>
          <core:set encode="0" var="project_name">${col[1]}</core:set>
   </core:forEach>
          
          <gel:log level="INFO"><![CDATA[*************${project_name},${project_code}]]></gel:log>
      
         </core:forEach>
     
         <gel:log level="INFO"><![CDATA[Did not enter core for each]]></gel:log>          
</gel:script>
2. Execute a process

Expected Results: process should execute successfully

Actual Results: process is throwing an error
Caused by: java.lang.IllegalArgumentException: Cannot invoke org.apache.commons.jelly.tags.core.ForEachTag.setStep on bean class 'class org.apache.commons.jelly.tags.core.ForEachTag' - null - had objects of type "<null>" but expected signature "int"

Cause

 <core:forEach indexVar="j" items="${result.columnNames}" step="${columnStep}" var="row">

Root cause of the problem is setting a null value (via evaluation of an undeclared variable) to the "step" attribute in forEach tag.

Environment

Release : 15.9.3

Component : CLARITY BUSINESS PROCESS MANAGEMENT

Resolution

Hardcode column value as per expected number of columns to be returned by the query, in this example 2 so step="${columnStep}" will be changed to step="2"

As part of the 3rd library cleanup and because we had a newer library which essentially can conflict with the old so we had to remove old to ensure no interference between them.

Suggest fixing the GELScript to actually declare the "columnStep" variable as the solution. But upon closer evaluation of places where this variable is used - almost each of the places the inner forEach loop is redundant and can be actually removed. 

Recommendation is to evaluate the GELScript to remove the inner forEach tag altogether where not needed or declare the variable "columnStep" properly with the correct value.