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

Pranav Bhagat
Kilo Sage

Hi

You can either use assignment rules or write a script in the associated workflows to set the assignment group.

Assignment rule

https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/task-table/task/t_AssignmentModuleRule.html

find_real_file.png

find_real_file.png

Workflow script

current.assignment_group = 'sys_id of the group';

Regards

Pranav

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Approaches below

1) You can have before insert BR on sc_request table

2) Use workflow run script in your workflow of Catalog Item

var req = current.request.getRefRecord();

req.assignment_group = 'group sysId'; // give the group sys_id here

req.update();

Regards
Ankur

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

Can I use the same code that you provided in point 2) in a business rule?

Hi,

I would suggest to use After insert BR on sc_req_item table

OR

Use workflow run script to update

Script I shared should work fine for both the above cases

Reason - By the time your REQ is generated you won't know for which Catalog Item's RITM this got generated and would cause issue

Regards
Ankur

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