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:13 PM
Could you test your script in Background-Scripts and see if it's generating any result?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 10:17 PM
Also, can you test this:
- var answer = [];
- var rs = new GlideRecord("u_provisioning_approvers");
- rs.addQuery("u_company", current.opened_by.company);
- rs.query();
- while (rs.next()) {
- answer.push(rs.getValue('u_capacity_managers'));
- }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 10:23 PM
I was trying to avoid that as my u_capacity_managers field already has the ability to either be a single sys_id or a comma separated list of sys_ids if there's more than one approver. I guess I could split that into an array, but that seems silly when I already have it in one of the formats expected. I'll try it though and see what happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2016 03:29 PM
Did you manage to get any results using that method?