ITSM | Group Approval based on companies and sub-companies

Milind1
Tera Contributor

Hi All,

 

We are in the situation where we need to send approvals dynamically to the groups. like we have 'ABC' company then we need to send approval to the 'ABC Approver'. We have 100+ companies and user can select the company value while raising the request using variable 'Requested for Company'.

 

We have written below script and it is working fine.

 

var answer = [];
var com = current.variables.requester_id.company.getDisplayValue();
var app = com + " Approver";
var U = new GlideRecord('sys_user_group');
U.addQuery('name', app);
U.addQuery('active', true);
U.query();
if (U.next()) {
    answer.push(U.sys_id);
}
 
We have child-parent structure in our instance as it is domain separated. we have situation like under 'ABC' company there are 5 child companies, lets say 'ABC-A', 'ABC-B' and so on.  If user select any child company then approval should go to 'ABC Approver'.
 
Now we are unable to do so, can someone guide us how we can achieve it using script as we want it dynamic due to huge number of companies

 

 

 

1 ACCEPTED SOLUTION

Alp Utku
Mega Sage

I would suggest you to create a custom table extended from "dl_matcher" table. On this table, you could hold company and approval matrix.

 

Then on the form, you can create a list collector variable to hold approval information. (This will be hidden variable) Assuming you have company information available on the form already.

 

You need to create data lookup definition for your catalog Item. Matcher Table will be your custom created table. Matcher variable will be your company and setter variable will be the hidden variable you created. For more information : https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/field-admini...

 

Lastly, on the workflow you could write below code on Approval activity to trigger approvals.

 

 

var answer = [];

answer.push(current.variables.<variable_name_of_list_collector> ;

 

 

View solution in original post

2 REPLIES 2

Hemanth M1
Giga Sage
Giga Sage

Hi @Milind1 ,

 

Why don't use Parent child relationships, Find out the parent company from the child company and use the above existing logic??

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Alp Utku
Mega Sage

I would suggest you to create a custom table extended from "dl_matcher" table. On this table, you could hold company and approval matrix.

 

Then on the form, you can create a list collector variable to hold approval information. (This will be hidden variable) Assuming you have company information available on the form already.

 

You need to create data lookup definition for your catalog Item. Matcher Table will be your custom created table. Matcher variable will be your company and setter variable will be the hidden variable you created. For more information : https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/field-admini...

 

Lastly, on the workflow you could write below code on Approval activity to trigger approvals.

 

 

var answer = [];

answer.push(current.variables.<variable_name_of_list_collector> ;