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.

How to set assignment group from catalog item when a request is submitted

dfsdf
Kilo Expert

Hi, I have created a service catalog item. When a user orders it, the request that is created should be assigned to a specific group. Please, help me achieve this.

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

this should work

(function executeRule(current, previous /*null when async*/) {

	var requestSysId = current.request;	// this would give you sys_id so use sys_id in query below
	var gr = new GlideRecord('sc_request');
	gr.addQuery('sys_id','=',requestSysId);
	gr.query();
	if(gr.next()){
			gr.assignment_group = 'tttttttttttttttttttttttttttttt'; // HR group sys_id
			gr.update();
	}
	
})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

I prepared this code snippet but it does not work.

My Br configuration:

(function executeRule(current, previous /*null when async*/) {

	// get request number from tirm record
	var requestNumber = current.request;
	var reqNumberOfRequest = '';
	var req = current.request.getRefRecord();
	// glide record on request table
	var gr = new GlideRecord('sc_request');
	gr.addQuery('number','=',requestNumber);
	gr.query();
	if(gr.next()){
			req.assignment_group = 'tttttttttttttttttttttttttttttt'; // HR group sys_id
			req.update();
	}
	
})(current, previous);


find_real_file.png

Hi,

Your BR is on which table?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

In sc_req_item  table

Hi,

this should work

(function executeRule(current, previous /*null when async*/) {

	var requestSysId = current.request;	// this would give you sys_id so use sys_id in query below
	var gr = new GlideRecord('sc_request');
	gr.addQuery('sys_id','=',requestSysId);
	gr.query();
	if(gr.next()){
			gr.assignment_group = 'tttttttttttttttttttttttttttttt'; // HR group sys_id
			gr.update();
	}
	
})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader