I added a new field and updated the code but it breaks the code on all the old tickets, how do I fix this? The above script does not work.
Do all five of your variables you are calculating from always have a value?
Yes, except in the case where the field does not exist on old tickets, then there are only 4 values.
You'll need to cope with the absence of the data in the script, so the script knows to not try to do anything with it.
Imagine you're trying to add 3 fields in the new script. Instead of
total += fieldValue3
use
if (fieldValue3) { total += fieldValue3 }
I'm not sure I'm following how to go about that. I have tried to different ways of going about it:
def total = ((bvInt + tcInt + rrInt + svInt) / sizeInt) * 100;def totalNull = ((bvInt + tcInt + rrInt) / sizeInt) * 100;def result;if(svInt==1 || 5 || 8 || 13){ return total}else { return totalNull}
OR
def total = ((bvInt + tcInt + rrInt + svInt) / sizeInt) * 100def totalNull = ((bvInt + tcInt + rrInt) / sizeInt) * 100def resultif(svInt!=null){ return total} else { return totalNull}
It looks like you're new here. Sign in or register to get started.