Referencing multi-option calculation fields in a calculation
Hello,
Hi,
I need some help with a Javascript calculation. The code below works if the category field has a single option but not with multi-option category fields: "Call Temp" is a multi-option category field and "One Count" is a calculation field in a related app which just has the number '1'. (Code pinched from one of Rainer's examples...)
var count = @All of One Count;
var status = @All of Call Temp;
var total = 0;
for(var i = 0; i < count.length; i++) {
if(status[i].indexOf("Cold Call") > -1){
total += count[i]
}
};
total
-
Hi Mike,
the code looks ok besides the fact that the value of count[i] is not recognized as a number but as a string - which you have to parse to a number:
+count[i]
or
Number(count[i])
or
parseInt(count[i])But if you have the field "One Count" only for counting items in this calculation you don't need that field. Just write
total++
instead of
total += count[i]Rainer
Please sign in to leave a comment.
Comments
1 comment