I'm writing a script with an outer loop on ABICapoGruppo and, for each ABICapoGruppo element, an inner loop on a variable number of elements.
For each outer loop element (ABICapoGruppo) the resulting table has to show: - an header row - a serie of detail rows - a summary row.
The number of detail rows is different for each ABICapoGruppo element.
At the moment I've written the following script (I've cut out all the details of data calculations).
Only the outer loop works fine, printing the description of ABICapoGruppo but no details from inner loop are produced.
I think that the key point is the inner array variable declaration that, for each outer loop cicle, is based on the current value of the outer loop element.
<#/*TABLE HEADER ROW*/#>
[......] <#<br />//START OF OUTER LOOPvar array = subset_uniquesList('ABICapoGruppo', SUBSET('ABICapoGruppo',null,'<>'));for (var i in array) { var val = array[i]; #> <#/*ABICapoGruppo HEADER ROW*/#>
[......] <#<br /> //START OF INNER LOOP array2 = subset_uniquesList('ABIAppartenente',SUBSET('ABICapoGruppo', '" + val+"') ); for (var j in array2) { var val2 = array2[j]; #> <#/*REPEATED DATA ROW*/#>
I'm trying to find the 'focal point' of the problem. It seems that using the below statements it's not possible to set the value of array2 depending on the value of val variable.
var array = subset_uniquesList('ABICapoGruppo', SUBSET('ABICapoGruppo',null,'<>')); //START OF OUTER LOOP for (var i in array) { var val = array[i]; var array2 = subset_uniquesList('ABIAppartenente',SUBSET('ABICapoGruppo', '"+ val+"') ); Writing the variables <#=array#>;<#=val#>;<#=array2#> I get the following:
Since you're using scripting, you will benefit from trying out the alpha build of 2.8. This has better support for scripting, such as syntax highlighting in the Content View, and better script error handling.