The CreatorCon Call for Content is officially open! Get started here.

Business rule for assignment

simonaivanova
Kilo Contributor

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?

1 ACCEPTED SOLUTION

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);



View solution in original post

10 REPLIES 10

I'm clear with the first part


You mentioned "Also based on the company, the related assignment group will be different" [PS] : Where is this info stored?


It is in the field "Company", taken from the active directory as information.


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);



dwada1
Kilo Expert

Hi Simona,



You may want to look into Assignment Lookup Rules for this:


http://wiki.servicenow.com/index.php?title=Defining_Assignment_Rules#gsc.tab=0



If this doesn't meet your needs, can you please give more detail as to what you are trying to accomplish?


Hello,


want to take the information from which office is the user and to assign the ticket to the relevant support group for that office.