- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 08:20 AM
In one of Catalog item, I created a single line text variable with Validation Regex as currency.
I need if condition if the Variable value >$5000 should go to approval task if no then no approval
I created condition like below screenshot and its not working as expected, approval is going <$5000 as well
Any once can suggest what is wrong with this?
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 07:14 AM
You should be using a Script with the Advanced box checked, which means you need to delete the Condition so that the script runs without being influenced by the condition. If it still doesn't work with the latest script I proposed with the temporary log to confirm the value, (which works in a background script using hard-coded values as your test case) try removing the $ as @mahemoodhus suggested, but in your script it would just be:
answer = ifScript();
function ifScript() {
var amt = parseInt(current.variables.expected_amount.toString().replace('$', '');
workflow.info('amount is ' + amt);
if (amt <= 5000) {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 08:50 AM
Try this without the condition, and check the Advanced box to use a script instead like this, or whatever logic works with what you're trying to do:
answer = ifScript();
function ifScript() {
if (current.variables.var_name <= '$5000') {
return 'no';
}
return 'yes';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 03:59 AM - edited 11-26-2024 04:03 AM
thank you for your reply,
I tried this script and its didn't work, same issue, I am not sure it field format issue or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 04:55 AM
You can try to force it to a string - even though this shouldn't be necessary, it can't hurt - then log the value
answer = ifScript();
function ifScript() {
var amt = current.variables.expected_amount.toString();
workflow.info('amount is ' + amt);
if (amt <= '$5000') {
return 'yes';
}
return 'no';
}
Note that the return values are 'yes' and 'no' not capitalized. What test amounts are you trying, what does the log show (viewable via the Workflow Context related link on the RITM, Log tab) and which values are returned for each? With this logic, the No path should lead to the Approval activity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 06:31 AM
I created condition like below
and issue,
If the amount starting above 5, like $6, $650, $75, $850 approval is going
if the amount starting below 5 number like $4, $45, $350 etc approval is not going
and >$5000 always going to approval which is correct