I have a repeat that collects several rounds of information that is then passed into the main layer to provide current information using a JavaScript function.
The issue I am having is that the calculation is not running unless I add another blank record to the repeat. I've tried adding calculationMode=always in bind::esri:parameters but it could be an error in the script
I created one I can share here attached. Using this in S123 WebApp for data entry, created in S123 Connect 3.15.165
FYI for anyone looking at this in the future, using the Join with a ',' causes an error in the script hence why you'll see I am using a +
function getFirstNonNullValue(vals,separator,reverse) {
let repeat = vals.split(separator);
if (reverse == 'true'){
for (let i = repeat.length-2;i >= 0; i--){
let val = repeat[i];
if (val != null && val.trim().length != 0){
return val;
}
}
}
else {
for (let i = 0;i <= repeat.length-1; i++){
let val = repeat[i];
if (val != null && val.trim().length != 0){
return val;
}
}
}
}
function getMergedValues(vals,separator,reverse) {
let repeat = vals.split(separator);
let mergedVals = '';
if (reverse == 'true'){
for (let i = repeat.length-2;i >= 0; i--){
let val = repeat[i];
if (val != null && val.trim().length != 0) {
mergedVals = mergedVals + repeat[i];
mergedVals = mergedVals + '\n------\n';
}
}
}
else {
for (let i = 0;i <= repeat.length-1; i++){
let val = repeat[i];
if (val != null && val.trim().length != 0) {
mergedVals = mergedVals + repeat[i];
mergedVals = mergedVals + '\n------\n';
}
}
}
return mergedVals;
}
Information is entered into repeat:
Populated after adding second record:
Hello @SpatialSean,
You don't need to use a JavaScript function you can use the indexed-repeat() function to do this. Something like the following should work:
indexed-repeat(${Capture_Info}, ${rpt_Info},count(${Capture_Info}))
Unfortunately it is not as simple as my example posted above. There are multiple questions within the repeat - some of which remain blank and when using indexed repeat it will pull the null values.