Calculated value script

Alon Grod
Tera Expert

Why am I getting '0' value all the time? What am I doing wrong?

Im trying to calculate a value using and then populate using calculated script.

 

1 ACCEPTED SOLUTION

Hi @Alon Grod ,

Return the calculated value as below :- Calculated value must be on u_saving field.

(function calculatedFieldValue(current) {

var a = parseInt(current.cost);

var b = parseInt(current.u_competitive_proposal);

var c = a - b;

if (c > 0){
return parseInt(c);
}
else {
return parseInt(0);
}

})(current);

  


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

3 REPLIES 3

shyamkumar VK
Kilo Patron

Hello @Alon Grod ,

can you please Include your script here? would be easy to analyze the issue

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

(function calculatedFieldValue(current) {

var a = parseInt(current.cost);

var b = parseInt(current.u_competitive_proposal);

var c = a - b;

if (c > 0){
current.u_saving = parseInt(c);
}
else {
current.u_saving = 0;
}
// return the calculated value

})(current);

Hi @Alon Grod ,

Return the calculated value as below :- Calculated value must be on u_saving field.

(function calculatedFieldValue(current) {

var a = parseInt(current.cost);

var b = parseInt(current.u_competitive_proposal);

var c = a - b;

if (c > 0){
return parseInt(c);
}
else {
return parseInt(0);
}

})(current);

  


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy