How can I identify all sys_templates that assign a ticket to a specific group?

JR42
Giga Guru

Hello, I am trying to identify all active templates in sys_template that assign the ticket to a specific group.

 

Can anyone help me with a background script that I can use for this?  I can input the group's sys_id into the script before running and want it to list the Template names.  So far my scripts appear to be finding templates, but are not printing anything out.

 

 

Thanks!

1 ACCEPTED SOLUTION

Slava Savitsky
Giga Sage

You don't actually need a script for that. You can simply filter the list of templates like this and then export it if needed:

https://INSTANCE.service-now.com/sys_template_list.do?sysparm_query=templateLIKEassignment_group=SYSID

View solution in original post

2 REPLIES 2

Slava Savitsky
Giga Sage

You don't actually need a script for that. You can simply filter the list of templates like this and then export it if needed:

https://INSTANCE.service-now.com/sys_template_list.do?sysparm_query=templateLIKEassignment_group=SYSID

Community Alums
Not applicable

Hi @JR42 ,

 

 

var groupSysId = 'your_group_sys_id_here';
var gr = new GlideRecord('sys_template');

var qry = "active=true^templateLIKEassignment_group=" + groupSysId;
gr.addEncodedQuery(qry);

gr.query();

if (gr.hasNext()) {
        while (gr.next()) {
        gs.print(gr.name + "\n");
    }
} else {
    gs.print('No templates found');
}

 

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar