Make template available for multiple groups

wiltonr
Giga Contributor

How can I share a template (for incident) with more than one group and not global? the current "group" field only lets us select one group. Anyone know an alternative? Or possibly a way to make the "group" field able to select multiple groups (like a Watch List looking field)?

I changed the group field type in our Dev instance from Reference to List and changed the size of the field and broke our template form.   Now I have to wait for support to fix our field type/length.   Once they fix it though, I still have the request to find a way to allow more than one group to apply a template.   In Demo, I created a List field on the sys_template table called u_groups and can add multiple groups to the field but I can't figure out how to allow the groups in that field to Apply Template - the option does not appear in the Context Menu.   How can I do this?

21 REPLIES 21

johan_strom
Kilo Contributor

Hi Rhonda,


A customer asked me to accomplish exactly what you trying here and I have a solution for you unless it's already solved.



1. I added a GlideList field called Groups (u_groups) at the template form.



2. Added the following to ACL sys_template read:



/** Start New Group list feature - add below original "var groupMatch" **/


var groupsMatch = false;


var usrsGrps = gs.getUser().getMyGroups().toArray();


for (var i = 0; i != usrsGrps.length; i++) {


  if (current.u_groups.indexOf(usrsGrps[i]) > -1) {


  groupsMatch = true;


  break;


  }


}


/** End New Group list feature **/



/** Start New Group list feature - add below original "if (groupMatch)"**/


if (groupsMatch)


  return true;


/** End New Group list feature **/



3. Change the answer in Business Rule SNC Template Query like this,



'global=true^ORuser=javascript:gs.getUserID()^ORgroup=javascript:getMyGroups()^ORu_groupsLIKEjavascript:getMyGroups()'




4. (Edit: March 5th, 2015) - Update the UI Macro "template_context" to make the templates show up in the Context Menu:


Look for "var mine = 'user=javascript:gs.getUserID()^ORgroup=javascript:getMyGroups()';"


Replace it with "var mine = 'user=javascript:gs.getUserID()^ORgroup=javascript:getMyGroups()^ORu_groupsLIKEjavascript:getMyGroups()';"




Hope that helps!



J.Gradén


Johan,


Thank you - We have not yet implemented a solution.   I will definitely try this - we are in the middle of a huge project so I don't want to try this just yet, but when I do I will let you know if it worked for us - thanks!


Rhonda


Apply Template --- Option is not working after sharing the template.



Can you please update what is missing here.


Johan,



Sorry to pull you back to May, 2016, but this looks like a really good guide to solving the described problem!



I tried to follow all of your steps, but my ITIL user in one of the specified groups still couldn't see the template I wanted him to see. I impersonated him, navigated to sys_template.list, I saw the following screen:



find_real_file.png



This indicates to me that the ACL doesn't quite work (I don't see the "Server Reboot," and believe it's the 1 that's hidden). Despite the brevity and clarity of the ACLs you wrote, I instead put in a broader ACL for sys_template READ that simply checks if a user is an ITIL user. Abel Tuter was still unable to see Server Reboot.



I hope you remember this general thread and are able to provide assistance.


Hello Garden - I tired the same. But in the template BAR i am still not able to get the correct output. kindly advise

 

 

if (templates_list == null) {
var templates_list = new GlideChoiceList();
var tt = new GlideRecord('sys_template');
var common = 'table=' + ${ref}.getTableName() + '^active=true';
var global = 'global=true';
var mine = 'user=javascript:gs.getUserID()^ORgroup=javascript:getMyGroups()^ORu_groupsLIKEjavascript:getMyGroups()';
var query = common + "^" + global + "^NQ" + common + "^" + mine;
tt.addQuery(query);
tt.orderBy('name');
tt.setWorkflow(false);
tt.query();
while (tt.nextRecord()) {
var roles = tt.roles;
if (jelly.jvar_session.hasRole(roles))
templates_list.add(tt.sys_id + '', tt.name + '');
}
}