Workflow Approval User Via Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 09:37 PM
I'm attempting to set up an approval using the "Advanced Additional Approvers Script". The script I'm using is shown below. u_capacity_managers is a User reference, and I can confirm that answer ends up being set to the sys_id of the correct user (I've printed it into a field to check via current.description = answer), BUT, the approval step just skips through as though no one is being set as the approver. Can anyone identify any problems with what I'm doing?
// Set the variable 'answer' to a comma-separated list of user ids and/or group ids or an array of user/group ids to add as approvers.
//
// For example:
// answer = [];
// answer.push('id1');
// answer.push('id2');
var rs = new GlideRecord("u_provisioning_approvers");
rs.addQuery("u_company", current.opened_by.company);
rs.query();
while (rs.next())
{
answer = String(rs.u_capacity_managers);
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 10:14 PM
Hi,
I have the same issue like that. Unfortunately, I don't have a solution as of now. What was happening to me is that there is only one approver assigned after the loop.
If you want a workaround, you can create a group where in the members will be added and the group will be assigned as the group approver.
1. Create a group
2. Add the members which will be your approvers
3. Your approval group in your approval process in the workflow must be your created group.
4. After the process ends, you can remove the approvers from the group.
Another is you will assign one approver to the approval process and copy the approval ticket in the approval table.
1. Assign one approver to the ticket in the approval process.
2. Create a run script after the approval which will contain the script to copy the approval ticket in the approval table.
3. It can be the whole script process or a script include call.
Hope this helps.
Thank you.
a.c.manlangit
serviceNow Developer - Philippines

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 10:19 PM
In my case no one gets assigned as the approver and that step ends up with a "skipped" state. If I run it in a background script, or I put in that debug print to current.description, I do get the sys_id of the person that should be the approver. So answer is definitely ending up equal to the sys_id of the user that I want it to be... but no approval gets created. I've just tried hardcoding myself into the top "Users" field - in that case I do get an approval request, but the "additional" approver from the script does not get one. Kind of feels like that script section just does nothing...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 10:40 PM
Hi,
plz replace the code line no 16 with follwoing
answer= rs.getDisplayBox('u_assignment_group ').value;
It may help you.
PS - Please mark Helpful, Like, or Correct Answer if applicable.
Thanks
Pradeep D J

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2016 03:15 PM
???
GlideRecord doesn't have a "getDisplayBox" method. What is that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2016 09:31 PM
getDisplayBox helps to fetch the displayed value of the reference fields.