How to assign users in Approval-User activity through script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2017 05:24 PM
In my workflow, I need to assign to approvers based on user region. I tried implementing this through a script in 'Additional approvers script'. But the workflow Approval-User activity being skipped when I try to assign approvers to answer array as shown below.
// 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:
//current.variables.assigned_to='4562471f13fccfc079c0b4a76144b0d0,d4193a21130d430079c0b4a76144b042';
//current.variables.assigned_to='4562471f13fccfc079c0b4a76144b0d0';
answer = [];
var gr=new GlideRecord('sys_user');
gr.addQuery('sys_id',workflow.scratchpad.user_sysid);
gr.query();
if(gr.next())
{
if(gr.department.name == 'Residential US Floors')
{
//Assign to 'Sam D Ruble'.
//Sam Ruble sys_id :5bac349edb8b7a04c1d57c1ebf96191e
answer.push('5bac349edb8b7a04c1d57c1ebf96191e');
}
if(gr.department.name == 'Residential Hard Surface')
{
//Assign to 'Scott Sandlin'.
//Scott Sandlin sys_id :ea494c7a0a0a3c1f00a5c2702b3c9a2a
answer.push('ea494c7a0a0a3c1f00a5c2702b3c9a2a');
}
if(gr.department.name == 'Residential Speciality Markets')
{
//Assign to 'Craig Callahan'.
//Craig Callahan sys_id :5bac349edb8b7a04c1d57c1ebf96191e
//answer.push('5bac349edb8b7a04c1d57c1ebf96191e');
//Setup Craig Callahan User account
}
if(gr.department.name == 'Commercial')
{
//Assign to 'Doug Enck'.
//Doug sys_id :196719c60a0a3c4901dec48da956e4b0
answer.push('196719c60a0a3c4901dec48da956e4b0');
}
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2017 04:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2017 08:35 PM
Thanks. I was trying with Sys Id's

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2017 09:05 PM
hi jpavanaryan,
does it works when u push it with user id?
don't forget to mark my response as the answer for other users reference.
cheers...:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 07:38 AM
Looks like I opened this question as Discussion. I can not mark this answer now. Sorry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 03:31 PM
no problem.