- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 03:52 PM
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,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 03:59 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 03:59 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 04:34 PM
Thank you! I moved the variables within the function, and it's working as expected now.