- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2020 12:59 AM
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2020 03:00 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2020 01:05 AM
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
Workflow script
current.assignment_group = 'sys_id of the group';
Regards
Pranav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2020 01:18 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2020 01:38 AM
Can I use the same code that you provided in point 2) in a business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2020 01:42 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader