Various approvers - advanced approval script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 10:23 AM
Hi there!
I am trying to write a script on an Approver activity in a workflow. On the catalog item, a user will select a group on the variable GroupName. If the group has a manager, I want the group manager to be the approver. If there is no group manager, I want the Business Service Owner to be the approver. If the group does not have a manager or a Business Service Owner, I have 3 specific people I want to be the approvers but only one needs to approve. Here is what I have been trying and it does work when the group has a manager but after that it is not working
var answer = [];
if (current.variables.GroupName.manager != '')
{answer.push (current.variables.GroupName.manager.sys_id.toString());}
else if (current.variables.GroupName.business_service_ownerDONOTUSE != '')
{answer.push(current.variables.GroupName.business_service_ownerDONOTUSE.sys_id.toString());}
else
{answer.push('13ece655db949340b3613caf9d9619f6');
answer.push('5bec2a55db949340b3613caf9d961948');
answer.push('5fec2a55db949340b3613caf9d961919');}
On the last else statement, those are the sys ids of the three people to be the approvers if no manager and no business service owner
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 11:02 AM
How do you confirm which table it is running on?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 11:18 AM
Check the workflow properties of this workflow. It should have the table name
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 12:02 PM
Ok thank you! I confirmed it is on the Requested Item workflow however it still isn't working 😕

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 01:12 PM
Can you run the below in you Approval - User script and let me know, what you see in the System logs
gs.log('+++++Manager is+++++++++'+current.variables.GroupName.manager.toString());
gs.log('+++++Service Owner+++++++++'+current.variables.GroupName.business_service_ownerDONOTUSE.toString());
var answer = [];
if (current.variables.GroupName.manager != '')
{
gs.log('+++++Manager Condition+++++++++');
answer.push(current.variables.GroupName.manager.toString());
}
else if (current.variables.GroupName.business_service_ownerDONOTUSE != '')
{
gs.log('+++++Business Service Condition+++++++++');
answer.push(current.variables.GroupName.business_service_ownerDONOTUSE.toString());
}
else
{
gs.log('+++++Last Condition+++++++++');
answer.push('13ece655db949340b3613caf9d9619f6');
answer.push('5bec2a55db949340b3613caf9d961948');
answer.push('5fec2a55db949340b3613caf9d961919');
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 01:24 PM
There are three errors that say: java.lang.NullPointerException: java.lang.NullPointerException: