Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Assignment groups, groups for roles.... why such confuse?

Brendan Hallida
Kilo Guru

Hi all,

Just want to start in saying that this could be me confusing myself!

From what I can gather - the best way to assign roles is to assign to groups, and then add the users to those groups.

This is fine and dandy - however we do not want to have these groups as assignment groups.

I followed the below wiki article, and assigned the group type as 'itil' and then modified the Assignment group's dictionary entry to contain type 'itil'

Configuring Group Types for Assignment Groups - ServiceNow Wiki

find_real_file.png

find_real_file.png

This works great, and as expected, until someone who is a member of more than one group.

What we have found is if you were to add an assignee in Assigned to before adding an assignment group, it will add the first group they are a member of, whether or not it is an assignment group with the 'itil' type or not.

Does anyone know how I can stop this from happening?

I hope I have explained this well enough......

Thanks in Advance!

Brendan

1 ACCEPTED SOLUTION

Hello Brendan,



Replace gr.group.type with group.type


View solution in original post

20 REPLIES 20

Just wondering if anyone had any insight into this back fill script?



Sorry for the page, but maybe you could point me in the right direction pradeepksharma?



Cheers,


Brendan


Hello Brendan,



Sure, can you please copy and paste script include "KSTaskAjax" code here.


Cheers Pradeep



Script Include:


API Name: global.KSTaskAjax


Client Callable: Yes


Accessible from: All application scopes



var KSTaskAjax = Class.create();




KSTaskAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {


});




KSTaskAjax.prototype.checkTaskSLABreached = function() {


  return String(KSTaskUtil.isResolveSLABreached(this.getParameter('sysparm_sysID')));


};




// finds a group to default for the current assigned to person


// just picks the first group; user needs to check this before saving


KSTaskAjax.prototype.getPrimaryGroupInfo = function() {



  var assignedTo = this.getParameter('sysparm_assignedTo');



  var retObj = {};


  retObj.groupID = '';


  retObj.groupName = '';


  retObj.assignedName = '';


  retObj.groupCount = 0;


  if (assignedTo != '') {


  //


  // Get the user record


  //


  var userRec = new GlideRecord('sys_user');


  if (userRec.get(assignedTo)) {


  retObj.assignedName = userRec.name.toString();


  //


  // count how many active assignment groups the assigned to belongs to.


  // only allow groups: with no type set (signifies assignment group)


  //                                   : that are active


  //


  var memberRec = new GlideRecord('sys_user_grmember');


  memberRec.addQuery('user', assignedTo);


  memberRec.addQuery('group.active', 'true');


  memberRec.addNullQuery('group.type');


  memberRec.query();


  while (memberRec.next()) {


  //


  // return the first assignment group encountered to auto populate the group on the task record


  //


  if (retObj.groupCount == 0) {


  if (retObj.groupID == '') {


  retObj.groupID       = memberRec.group.toString();


  retObj.groupName   = memberRec.group.name.toString();


  }


  }


  retObj.groupCount++;


  }


  }


  }



  var json = new JSON();


  var returnData = json.encode(retObj);


  return returnData;


};


Hello Brendan,



To filter records by group type ITIL you have to add the below line after line no 38.


  memberRec.addQuery('group.type', ' Copy and Paste ITIL SYS_ID HERE');


Thanks for this Pradeep,



I am having a hard time where to find the sys id of the group type...   Do you know where I can get that?



Cheers,


Brendan