- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 10:59 AM
Hello,
I need to populate the assignment group field in the incident form by using either BR, assignment rule or an inbound email action based on the callers location as I assign a different group based on location. Nothing I have tried is populating this field.
I have tried every approach and I had it working and now it no longer works.
Here is what I tried for assignment rule
if (current.caller_id.city == "Cincinnati")
current.assignment_group.setDisplayValue("Local Services - Cincinnati");
else if (current.caller_id.city == "Columbus")
current.assignment_group.setDisplayValue("Local Services - Columbus");
else if (current.caller_id.city == "Cleveland")
current.assignment_group.setDisplayValue("Local Services - Cleveland");
else if (current.caller_id.city == "Dayton")
current.assignment_group.setDisplayValue("Local Services - Dayton");
else if (current.caller_id.city == "Chicago")
current.assignment_group.setDisplayValue("Local Services - Chicago");
else if (current.caller_id.city == "Indianapolis")
current.assignment_group.setDisplayValue("Local Services - Indianapolis");
else {
current.assignment_group.setDisplayValue("Enterprise Customer Support");
}
TABLE: Incident
Conditions: Category = IT - Helpdesk
Contact Type = Email
Does not populate assignment rule
-------------------------------------------------------------------------------------------
Inbound Email Action I tried:
if(email.recipients.indexOf('onboardingtest@mycompanyemail.com') > - 1){
gs.log('Create new incident');
gs.log('gr.caller_id.email ' + current.caller_id.email);
gs.log('email from ' + email.from);
var gr = new GlideRecord('sys_user');
gr.addQuery('email', email.from);
gr.query();
if (gr.next()) {
// It's a user
// It's a user
current.caller_id = email.from;
current.description = email.body_text;
current.short_description = email.subject;
current.caller_id.city = email.from.city;
current.category = "IT - Helpdesk";
current.incident_state = 1;
current.contact_type = "email";
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
var ag = current.caller_id.city;
ag = String(ag);
gs.log(" AG is ? "+ ag );
switch(ag){
case 'Cincinnati':
var c = 'Local Services - Cincinnati';
assignment_group = c;
current.assignment_group = 'c370fe4537145280dc1ca6d2b3990e4a';
gs.eventQueue('new_call.alert.localcincy', current,gs.getUserID(),gs.getUserName());
break;
case 'Chicago': var c ='Local Services - Chicago';
current.assignment_group = c;
gs.eventQueue('new_call.alert.localchicago', current,gs.getUserID(),gs.getUserName());
break;
case 'Columbus': var c ='Local Services - Columbus';
current.assignment_group = c;
gs.eventQueue('new_call.alert.localcolumbus', current,gs.getUserID(),gs.getUserName());
break;
case 'Cleveland': var c ='Local Services - Cleveland';
current.assignment_group = c;
gs.eventQueue('new_call.alert.localcleveland', current,gs.getUserID(),gs.getUserName());
break;
case 'Dayton': var c ='Local Services - Dayton';
current.assignment_group = c;
gs.eventQueue('new_call.alert.localdayton', current,gs.getUserID(),gs.getUserName());
break;
case 'Indianapolis': var c ='Local Services - Indianapolis';
current.assignment_group = c;
gs.eventQueue('new_call.alert.localindy', current,gs.getUserID(),gs.getUserName());
break;
default: var c ='Enterprise Customer Support';
current.assignment_group = c;
gs.eventQueue('new_call.alert.enterprisesupport', current,gs.getUserID(),gs.getUserName());
}
//current.category = "request";
current.state = 1;
//current.notify = 2;
current.contact_type = "email";
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if (email.body.priority != undefined)
current.priority = email.body.priority;
current.insert();
}else{
current.description = '---Warning, This caller was not recognized. Dumping email data below: --- ' + ' Recipients of this email: ' + email.recipients + ' ' + ' Email Body: ' + email.body_text;
current.short_description = email.subject;
var c ='Enterprise Customer Support';
current.u_assignment_group = c;
gs.eventQueue('new_call.alert.enterprisesupport', current,gs.getUserID(),gs.getUserName());
current.insert();
}
//ASSIGNMENT RULE
//current.category = "request";
current.state = 1;
//current.notify = 2;
current.contact_type = "email";
if (email.body.assign != undefined){
current.assigned_to = email.body.assign;
}
if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high")
current.priority = 1;
}
if (email.body.priority != undefined){
current.priority = email.body.priority;
gs.log('email recipients:' + email.recipients);
}
gs.log('email recipients:' + email.recipients);
gs.log('end of create incident inbound action');
current.update();
}
I would appreciate any help!
Thank You,
Steele
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 01:38 PM
Adding this to my Inbound email action solved all my issues
current.caller_id = gr.sys_id;
current.caller_id.city = gr.city;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 11:23 AM
Hi Steele,
If you know which specific group to assign to, then you could assign this way, using business rule.
if (current.caller_id.city == "Cincinnati"){
current.assignment_group = sys_id of 'Local Services - Cincinnati' group;
current.update();
}
and likewise.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 11:29 AM
In response to the previous, you should not use current.update() in a business rule.
I don't think your script logic is off in those, so I would make sure that your users' city fields are populated, that you have them all correct (it's case sensitive), and that the group names are correct.
That being said, this is a lot of logic to store in a script and isn't very scalable, so I would use the relationships in ServiceNow to drive this. I would add a field to your location table called Support group, then you can base the assignment on the relationship from the caller to the location on the user table to the field on the location table. Then your before insert business rule would look like this:
current.assignment_group = current.caller_id.location.u_support_group;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 11:34 AM
Thanks for the correction Brad!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 12:03 PM
Thank you for the suggestions. I have one thing to add.
I have an inbound email action creating the incident. And Ideally it would be there to set the assignment group and have it populate. I resorted to assignment rules and BR because I could not get this working.
I set a BR on the Incident Table / Before / When Category is IT - Helpdesk and Contact Type = Email and Caller_id.City = Cincinnati
Set Assignment Group to Local Services - Cincinnati
When I create an incident this works. When I email an incident in the BR does not run. Any ideas?