- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 07:22 AM
Dear folks,
I have a workflow in which users select from 1 to N values displayed in a list collector; I have a requirement that each value needs to go through an approval process and might be approved/rejected without that affecting the other values collected in the list.
So if for example a user selects Value1 and Value2 from the list collector, there will be an approval for Value1 and another approval for Value2. I was able to implement this with the help of this community, but now I have a last hurdle that I need help with: in each approval, the email displays all the values that the user selects (Value1 and Value2) instead of the corresponding value that is being submitted to the approval record.
The approvers won’t be able to discern what they are being asked to approve; how do I reference the specific value from the list collector in the notification record or the email script? I can share the code I used in this workflow if needed.
Regards,
ubido
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 11:57 AM
- "I should insert a condition on the current Approval Request notification so that it won't fire in this workflow" - Yup, well I don't know if you can exclude a workflow, but you should be able to exclude based on some value of your table/form
- "which one branch continuing to the Approval and working just as it is now (except that the notification will not fire) and another branch to an email event to do what you suggest" - Yup again 🙂
- "except that I don't need a script to look through the apprv_ar array " - Ah I thought you wanted to send out a mail for every entry in your array. But if you only need to send out one mail then you indeed do not have to run through the array again.
- "How do I make a reference to a parameter in the notification Message field?" - In your workflow script, use gs.eventQueue("Your event name", current, workflow.scratchpad.apprv_ary[N], a_second_parameter_if_you_need_one); to call the event, then in your email notification body, use ${event.parm1} to display it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 07:55 AM
Hi,
you need to use user approval workflow activity; in the script section set the answer variable with the value of list collector
sample script below; it would set the list collector into answer variable
if 4 users selected then 4 approval records would be created one for each user
answer = [];
var val = current.variables.<variableName>.toString();
answer = val.split(',');
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 08:37 AM
Thanks for your reply Ankur!
I already used a similar logic to split the values that are input via the list collector at the beginning of the workflow (see code attached):
- Initialize.js: Gets the values from the list collector and add them to an array
- If Statement.js: use an "If" activity to determine if a value has been selected; if true, return "yes" and send to approval group activity
- Approval push.js: Runs in the approval group activity to use the value selected by the user to find out what is the approval group.
It is at this point that I ran into the problem I described; I have the value selected by the user from the list collector in the workflow.scratchpad.apprv_ary[0] variable. That is what I want to display in the approval email and the question is how?
Regards,
ubido
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 10:50 AM
How about disabling the automatic approval e-mails for this request, and in your workflow use a script that loops through your apprv_ar array, and trigger an mail event in each loop iteration, with the value of .apprv_ary[x] as a parameter. That parameter can then be used in your custom approval e-mail. (although this might fix your issue with the email content, the approval record on the portal will still show all variables I think)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 11:41 AM
Thanks for the suggestion premer! If I understand you correctly I should insert a condition on the current Approval Request notification so that it won't fire in this workflow, correct? Then I could insert a Branch activity between the If condition and the Approval Group activity, which one branch continuing to the Approval and working just as it is now (except that the notification will not fire) and another branch to an email event to do what you suggest?
Is that what you're suggesting? It seems that it might work, except that I don't need a script to look through the apprv_ar array as at that point I have the actual user selection in the workflow.scratchpad.apprv_ary[N] and passing it as a parameter should be an easy thing to do. How do I make a reference to a parameter in the notification Message field? I believe I can figure that out, but if you happen to have the answer at hand I'll appreciate it.
I will provide feedback once I have this working.
Regards,
ubido