Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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  ||  10x 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  ||  10x 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader