- 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-21-2016 07:21 AM
Hi Alex:
Looks like you don't need the double quotes surrounding your variable. Remove it and also only one = sign, not ==. Try these two changes. Hopefully, it should work.
Cheers.
Danny
P.S: Mark the answer as 'Helpful' and 'Correct' if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2016 07:23 AM
answer = ifScript();
function ifScript() {
if (current.variables.item == "BPCS/ERPLx") { // make sure "BPCS/ERPLx" is the value of the variable.
return 'yes';
} else
return 'no';
}
The script I have for Approval - User
answer = [];
//answer.push(current.variables.manager); // this will be true only if you have an variable with name manager which stores the value of manager of requester
answer.push(current.request.requested_for.manager); // dot walk to manager of requested_for
Hi Alexandru,
Please check the above suggested code.
I have commented out line no 13. If you have variable with name manager which points to the requested for manager, then you can remove the comments and put it on line 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2016 07:38 AM
Hey Deepak,
Thank you for your fast reply.
I tried your suggestion but unfortunately it didn't work. The workflow ignores the IF and the Approval again
Thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2016 07:46 AM
Can you please cross check your variable name once is it "item" correct ?
And also let me know what is the type of "item" variable.