- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2018 05:21 AM
Hi,
We have variable "Total Cost" in a service catalog form. It is Single Line text variable.
It will have values like 10000 or 20000 or 30000 etc.. like this.
here issue is in IF activity how can i compare the values like greater than or less than, based on that if condition it will route for different approvals.
Here is the script I am using in IF activity in workflow.
This code is not working and by default it is marking IF activity as "NO" and request is getting cancelled.
requirement is IF grand_total value is greater than 10000 it return as "true" , if less than that it should return as "false"
var Grandtotal = current.variables.grand_total.getValue();
function ifScript() {
if (Grandtotal > 10000) {
return 'yes';
}
return 'no';
}
Anyone please help guide on this.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2018 06:19 AM
pass the variable in
var Grandtotal = parseInt(current.variables.grand_total.getDisplayValue());
answer = ifScript(Grandtotal);
function ifScript(number) {
if (number > 10000) {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2018 05:56 AM
Can you try this
var Grandtotal = parseInt(current.variables.grand_total.getValue());
function ifScript() {
if (Grandtotal > 10000)
return 'yes';
else
return 'no';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2018 06:01 AM
Hi Shashikanth and David,
Thanks for responding.
I have tried using logs it is showing as TYPE of "Number"
and I have tried the code as shashikanth and raju suggested. It is still marking IF activity as "NO".
I am not sure what is the error.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2018 06:12 AM
Are you calling answer = ifScript(); this in your activity?
answer = ifScript();
var Grandtotal = parseInt(current.variables.grand_total.getValue());
function ifScript() {
if (Grandtotal > 10000)
return 'yes';
else
return 'no';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2018 06:18 AM
answer = ifScript();
var Grandtotal = parseInt(current.variables.grand_total.getDisplayValue());
function ifScript() {
if (Grandtotal > 10000) {
return 'yes';
}
return 'no';
}
try this code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2018 06:19 AM
pass the variable in
var Grandtotal = parseInt(current.variables.grand_total.getDisplayValue());
answer = ifScript(Grandtotal);
function ifScript(number) {
if (number > 10000) {
return 'yes';
}
return 'no';
}