- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 01:41 PM
Hello,
I need to create business rule for direct assignment of a ticket. But I need to take the company property and to assign it to the group,
which is related to the concrete company.
For example: if the ticket comes from Company Naxex, it should be assigned to group SN_LDS. How I can write it in a script?
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 02:23 PM
Here you go. Create a BEFORE business rule and modify the script as per your need.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', current.caller_id);
gr.query();
if(gr.next())
{
var usrComp = gr.company;
var gr1 = new GlideRecord('core_company');
gr1.addQuery('sys_id', usrComp);
gr1.query();
if(gr1.next())
{
current.assignment_group = gr1.<FIELD COLUMN NAME OF GROUP';'
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 01:45 PM
Hello Simona,
You can configure this via Assignment rules. More info here.
Defining Assignment Rules - ServiceNow Wiki
The other option is the Business Rules as you have mentioned (in case you want this to work insert/update operation). However no script is required and it can be configured via filter conditions "When to run" and action tab.
More info here.
Business Rules - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 01:50 PM
Hi Pradeep,
unfortunately we have business rule for assignment of all of the tickets to a concrete group, which will overwrites the assignment rule. That's why I decided to write a new business rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 01:54 PM
Thanks SImona for the update. in this case you can adjust your script in the previous Business rule
Script will be
if(current.company.getDisplayValue() == 'PASS COMPANY NAME HERE')
{
current.setDispalyValue('assignment_group', 'PASS ASSIGNMENT GROUP NAME HERE');
}
Please make sure field column names are correct as per your table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 02:05 PM
The thing is that the company is not a static field, but should be taken as the information from the active directory, related to the user ID.
Also based on the company, the related assignment group will be different.