If requested_by.manager is blank, User Approval is being skipped in Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2012 04:06 PM
In our Change Request workflows the first step is to get approval from the manager of the person requesting the change. This is being done by using the Approval - User option with ${requested_by.manager} in the Users. This works fine as long as the requested_by has a manager associated with them, if manager is blank the change gets automatically approved and the workflow keeps going. I haven't been able to find a way to change this behavior.
Ideally what I would like to do is have another group look at the change if the requested by manager is null, I just haven't figured out how to do this. As a long shot I tried: if (current.requested_by.manager=="NULL") {answer='group ID';}, but that didn't work. The change was still approved automatically.
I was thinking it might be possible to do this with an IF statement in the workflow. If current.requested_by.manager==NULL return YES and the YES point to a group approval with the group I need to look at the change. and with NO pointing to a user approval that uses the requested_by.manager variable like I'm doing now.
It sounds like that would work but for some reason I keep thinking there is a more elegant way of doing this.
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2012 05:16 PM
Check out the final section on this guru page for an answer to this problem.
http://www.servicenowguru.com/scripting/change-management-workflow-approval-scripts-servicenowcom/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2012 07:22 AM
What am I missing? This is what I'm trying based on that article:
var answer = [];
//Requested by and assignment group manager approval
if(current.requested_by.manager.active){
answer.push(current.requested_by.manager.sys_id);
}
//Ensure 'Change_approvers' group gets added if no other approvers (optional)
if(answer.length == 0){
grpName = 'Change_approvers';
//Query for change management group
var cGrp = new GlideRecord('sys_user_group');
cGrp.get('Change_approvers', grpName);
answer.push(cGrp.sys_id);
}
The workflow is still moving on.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2012 07:30 AM
Make sure that your group name is exactly the same as the group name in your table. Also, make sure that you have active users in your 'Change_approvers' group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2012 01:41 PM
My first thought is that
current.requested_by.manager.active
is causing an exception because manager is null. Change it to
!current.requested_by.manager.isNil()
and then check to see if the manager is active.