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

@Ankur Bawiskar I've never written back to the email logs before, what's the simplest line of code that I can put inside the if statement in order to accomplish this? 

@nickm5816667392 

you can add gs.info() within that IF statement

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

I apologize for so many follow ups. I may have to table this one for now as I'm taking up way too much of your time for something that I should be learning in my upcoming training.

 

This is how I left it, I added a log both inside and outside of the if statement. I wanted to see something get logged regardless of whether the if statement was true or not. Does this log result end up appearing in the same email log in which I get to see things like the following?

 

05-30-2025 15:21:11
InformationProcessed 'Create Incident', updated incident :INC0107125

 

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

@nickm5816667392 

it should come in system logs

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

@Ankur Bawiskar I accepted your original response as a solution, thank you! Here's where I was going wrong: I was attempting to set the priority. HOWEVER, in our system the priority is calculated based off of a formula that looks at both Impact and Urgency. Once I tweaked my statement to set these variables, priority was automatically updated. 

 

Thanks for your patience with me!