- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 04:42 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 08:32 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 11:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2024 09:40 PM
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();
    }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2024 10:58 PM
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();
  }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 08:32 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 11:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2024 09:40 PM
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();
    }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2024 10:58 PM
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();
  }