- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2016 06:58 AM
Hello,
We have a workflow named "Software Request" with different assignment groups based on what 'item' is selected in the service catalog form or assignment groups based on requester's location.
We would like to add a "manager approval" when a certain item is selected on the form. To be more specific, when the value "BPCS" is selected in the variable "Item" the workflow must trigger an approval and send it to the requester's manager. This must apply ONLY for BPCS value. Any other value must continue the normal workflow with not approvals and a task created at the end.
My workflow:
The script if have for the "If":
answer = ifScript();
function ifScript() {
if (current.variables.item == "BPCS/ERPLx") {
return 'yes';
} else
return 'no';
}
The script I have for Approval - User
answer = [];
answer.push(current.variables.manager);
The approval is not triggered and the workflow is ignoring the "If" and the "Approval" user and I don't know why.
Any ideas are much appreciated.
Thanks,
Alex
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2016 01:10 AM
Hi Alex,
current.variables.item will store the "sys_id" for reference type variable.
You can check the same by generating log statements in your code.
Better way to deal with this kind of scenarios in case of reference and choice list field is to use getDisplayValue() method against variable.
Your modified code should be
- function ifScript() {
- if (current.variables.item.getDisplayValue() == "BPCS/ERPLx") { // BPCS/ERPLx is the value you should see when variable is populated //with corresponding record
- return 'yes';
- } else
- return 'no';
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2016 12:15 AM
Hi Ravi,
I doublecked and the name of the variable is "item" indeed.
The variable type is Reference.
Thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2016 01:10 AM
Hi Alex,
current.variables.item will store the "sys_id" for reference type variable.
You can check the same by generating log statements in your code.
Better way to deal with this kind of scenarios in case of reference and choice list field is to use getDisplayValue() method against variable.
Your modified code should be
- function ifScript() {
- if (current.variables.item.getDisplayValue() == "BPCS/ERPLx") { // BPCS/ERPLx is the value you should see when variable is populated //with corresponding record
- return 'yes';
- } else
- return 'no';
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2016 01:33 AM
Hi Deepak,
It works !
Thank you very much for your help!
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2016 01:38 AM
Always make sure that for reference field you have to pass sys_id.
If you wish to pass the text then you have to use .getDisplayValue();
Hope it will help you