How to set incident priority from email body
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 11:09 AM
I need to search for text “p=” or “p= “ in the email body and populate the priority field accordingly.
If found(for example p=2), then we need to populate the same priority. If not found à default value “3 – Moderate”.
im trying to user this script, but its not working:
if (email.body.p != undefined) {
if (email.body.p == "1" || email.body.p == "2" || email.body.p == "3" || email.body.p == "4" || email.body.p == "5") {
current.priority = email.body.p;
}
} else {
current.priority = 3;
}
current.insert(); // create new incident
Can anyone please help?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 11:38 AM
Hi,
Priority is driven by a priority look-up matrix that is based on urgency and impact. So I'd suggest you should be setting urgency and impact value in script and that will ultimately set the value of priority.
Sample script would be something like this.
if (email.body.p == "1" ) {
current.urgency = ""; //add the value of urgency
current.impact = "";
} else if(email.body.p == "2" ) {
current.urgency = "";
current.impact = "";
} else if(email.body.p == "3" ) {
current.urgency = "";
current.impact = "";
} else if(email.body.p == "4" ) {
current.urgency = "";
current.impact = "";
} else if(email.body.p == "5" ) {
current.urgency = "";
current.impact = "";
} else {
current.urgency = "3";
current.impact = "3";
}
current.insert();
Add impact and urgency value accordingly.
In case for any reason you want to go for priority directly then try below
var priorityStr = email.body.p.toString();
if ( priorityStr == "1" || priorityStr == "2" || priorityStr == "3" || priorityStr == "4" || priorityStr == "5") {
current.priority = priorityStr;
} else {
current.impact= "3";
current.urgency= "3";
}
current.insert();
Regards,
Muhammad
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 12:11 PM
hi,
both answers are not working. In my email body, i tried to type all of these combinations:
p=4, p = 4, p = '4', p='4'.
but unfortunately it always sets the "if not found" value (in our case, p=3).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 12:55 AM
both of them are not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 07:34 PM
Ah I think we are missing current.update()
. Please use this inside if...else statements and see if it works.
Also, please log the value of email.body.priority to see what actually you are getting.
gs.info(email.body.p);
Muhammad