Set Incident Urgency based off Caller Group (Emailed Incidents)

nickm5816667392
Tera Contributor

We currently allow users to open incidents by emailing our instance. These incidents are low impact/urgency/priority by default. 

 

We're looking to automatically set the Urgency to High in the event one of our VIP users sends this email. These VIP users exist in an AD security group that syncs with ServiceNow.

 

We're running Yokohama. Hoping there is something OOB we can rely on. Thanks in advance!

1 ACCEPTED SOLUTION

@nickm5816667392 

you can check if the user who is responding is member of that group

something like this but please enhance

//  Note: current.opened_by is already set to the first UserID that matches the From: email address

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.description = email.body_text;
current.short_description = email.subject;


if(gs.getUser().isMemberOf('Group ABC')){
    current.priority = 2; // high
}

current.category = "inquiry";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
//current.assignment_group = 'ff796f1847314a1006ec046fe16d4379';
/*
if (email.body.assign != undefined)
   current.assigned_to = email.body.assign;

if (email.importance != undefined) {
   if (email.importance.toLowerCase() == "high") {
        current.impact = 1;
        current.urgency = 1;
   }
}

if (current.canCreate())*/
current.insert();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

15 REPLIES 15

I'll be trying this early next week and will report back, thanks!

@nickm5816667392 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, I feel I'm almost there! With a long holiday weekend I did not get a chance to test this until today.

 

Here's what I did:

1) sent an email to the system from myself and confirmed the priority was set to low.

2) added the following code to create incident:

if(gs.getUser().isMemberOf('VIP')){
    current.priority = 2; // high
}

 

3) added myself to VIP

4) sent a second email

 

The priority was still set to low. I did confirm that Create Incident was invoked by looking at the email logs:

Processed 'Create Incident', updated incident :INC0106283

 

Thoughts? 

@nickm5816667392 

did you add logs and see if it went inside that IF?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

No, but that is the logical next step. I've never done this in ServiceNow so I need to do a little research.

 

It looks like I can use the gs.log feature. I will test this when I log in in a couple of hours.