Various approvers - advanced approval script

Hannah C
Giga Expert

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

17 REPLIES 17

Can you do a show workflow on the Requested Item record and post the screenshot of the workflow and keep the curson on the approval-user activity while taking the screenshot


Please mark this response as correct or helpful if it assisted you with your question.

find_real_file.png

Try using this script

 

gs.info('+++++Manager is+++++++++'+current.variables.GroupName.manager.toString());

gs.info('+++++Service Owner+++++++++'+current.variables.GroupName.business_service_ownerDONOTUSE.toString());

var answer = [];

if (current.variables.GroupName.manager != '')
{

gs.info('+++++Manager Condition+++++++++');

answer.push(current.variables.GroupName.manager.toString());

}

else if (current.variables.GroupName.business_service_ownerDONOTUSE != '')
{

gs.info('+++++Business Service Condition+++++++++');

answer.push(current.variables.GroupName.business_service_ownerDONOTUSE.toString());

}

else
{

gs.info('+++++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.

That at least made it to where it was "Waiting for Approval" however there are no approvers listed

But what do you see in the system log


Please mark this response as correct or helpful if it assisted you with your question.