
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 07:54 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 08:55 AM
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
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 08:55 AM
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
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 09:41 AM - edited 06-25-2024 09:41 AM
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