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

BODDU SHIVA GOP
Tera Contributor

suppose we have to tables, one is table1 and another is table2. if one record is inserted in table1, the same record is inserted in table2. now I need a javascript program for, if one record is deleted in table1, the same record has to be deleted in table2.