write a script include to get sysid of assignment group

shikhakamboj
Kilo Expert

i want to write a script include to get the sysids of assignment groups and than call that script include in client script.

need example.

6 REPLIES 6

chuckn
Kilo Guru

I'm curious: why doesn't this exist out of box?  If the name of a sys_user_group is unique, then it would seem pretty straight-forward to have one call (a la gs.getUserID()) to get the sys_id of a specified group name, no? (@Chuck Tomasi)

Thanks!

I had a slightly different need: just tell me the sys_id of a specified group name.  Here's my code:

var GetGroupSysIDAjax = Class.create();
GetGroupSysIDAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	getAssignmentGroupSysID : function(gr_name){
		var gr = new GlideRecord('sys_user_group');
		gr.addActiveQuery();
		gr.addQuery('name', gr_name);
		gr.query();
		if (gr.next())
			return gr.getUniqueValue();
	},
	type: 'GetGroupSysIDAjax'
});

Put that in a client callable script include named "GetGroupSysIDAjax" and call it as follows:

gr.assignment_group = new GetGroupSysIDAjax().getAssignmentGroupSysID('Service Desk');