Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Comparing integer values in workflow condition not working

MB12
Kilo Sage

Hello Experts,

 

I'm trying to compare two integer values in a workflow if condition, however it's not working. The booking value I'm using is 10,000.00, but my script returns "no." I tried to add the two values, and it returns 10,010. I get the correct numbers when logging maxcap and Amount. Am I doing something wrong? 

answer = ifScript();
var maxcap = parseFloat(10.00);
var str = current.variables.booking_value.toString().replace(/,/g, '');
var Amount = parseFloat(str);


function ifScript() {
if(Amount > maxcap) {

return 'yes';

}

return 'no';
}

Thank you,

1 ACCEPTED SOLUTION

Saurabh Gupta
Kilo Patron

Hi,

Please try below code, you have defined the variable outside the function ifScript()

answer = ifScript();



function ifScript() {
var maxcap = parseInt(10.00);
var str = current.variables.booking_value.toString().replace(/,/g, '');
var Amount = parseInt(str);
if(Amount > maxcap) {

return 'yes';

}

return 'no';
}

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Regards,
Saurabh


Thanks and Regards,

Saurabh Gupta

View solution in original post

2 REPLIES 2

Saurabh Gupta
Kilo Patron

Hi,

Please try below code, you have defined the variable outside the function ifScript()

answer = ifScript();



function ifScript() {
var maxcap = parseInt(10.00);
var str = current.variables.booking_value.toString().replace(/,/g, '');
var Amount = parseInt(str);
if(Amount > maxcap) {

return 'yes';

}

return 'no';
}

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Regards,
Saurabh


Thanks and Regards,

Saurabh Gupta

Thank you! I moved the variables within the function, and it's working as expected now.