short description in incident is 'Software' then that incident should be assigned to Software group

NishantDhole
Mega Guru

Hello,

 

Please find below use case which is commonly ask in interviews.

 

If the short description in incident form is 'Software' then that incident should be assigned to
Software assignment group. how can we achieve it and write a script for that.

 

Please tell me how to solve this.

4 ACCEPTED SOLUTIONS

Elijah Aromola
Mega Sage

You don't need to write a script for this at all. You can use an assignment rule with the condition builder, or a business rule if you need more options for when it should set the assignment group.

View solution in original post

Sid_Takali
Kilo Patron
Kilo Patron

Hiteish222
Kilo Guru

Hi @NishantDhole ,

we can use multiple ways to achieve this scenario like assignment rule, business rule.

But as you mentioned this question is asked in interview & interviewer asking you to write a script for it instead of assignment rule,

You can use below code in background script :

 

var inc = new GlideRecord('incident');
    inc.addQuery('short_description', 'Software');
    inc.query();
    while(inc.next()){
      inc.assignment_group = 'enter sys_id of assignment_group here';
      inc.update();
    }

View solution in original post

Hiteish222
Kilo Guru

Hi @NishantDhole   ,

we can use multiple ways to achieve this scenario like assignment rule, business rule.

But as you mentioned this question is asked in interview & interviewer asking you to write a script for it instead of assignment rule,

You can use below code in background script :

var inc = new GlideRecord('incident');
inc.addQuery('short_description', 'Software');
inc.query();
  while(inc.next()){
    inc.assignment_group = 'enter sys_id of assignment_group here';
    inc.update();
  }

 

View solution in original post

5 REPLIES 5

Elijah Aromola
Mega Sage

You don't need to write a script for this at all. You can use an assignment rule with the condition builder, or a business rule if you need more options for when it should set the assignment group.

Sid_Takali
Kilo Patron
Kilo Patron

Hi @NishantDhole I would suggest you to Create an Assignment Rule and it can be easily maintained. 

https://www.servicenow.com/community/developer-forum/how-to-update-incident-assignment-group-from-ke...

Hiteish222
Kilo Guru

Hi @NishantDhole ,

we can use multiple ways to achieve this scenario like assignment rule, business rule.

But as you mentioned this question is asked in interview & interviewer asking you to write a script for it instead of assignment rule,

You can use below code in background script :

 

var inc = new GlideRecord('incident');
    inc.addQuery('short_description', 'Software');
    inc.query();
    while(inc.next()){
      inc.assignment_group = 'enter sys_id of assignment_group here';
      inc.update();
    }

Hiteish222
Kilo Guru

Hi @NishantDhole   ,

we can use multiple ways to achieve this scenario like assignment rule, business rule.

But as you mentioned this question is asked in interview & interviewer asking you to write a script for it instead of assignment rule,

You can use below code in background script :

var inc = new GlideRecord('incident');
inc.addQuery('short_description', 'Software');
inc.query();
  while(inc.next()){
    inc.assignment_group = 'enter sys_id of assignment_group here';
    inc.update();
  }