- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-15-2022 10:34 AM
I have an inbound action to create incidents.
I am trying to set the Priority based on the Subject and the email flag
Here is my code
Her is what I need to do:
If the email is flagged important set the Priority = Critical
If the email is flagged important and the subject contains the word urgent set the Priority = Critical
If the email is NOT-flagged important and the subject contains the word urgent set the Priority = Critical
If the email is NOT Flagged important and the subject DOES NOT Contain the word urgent set the Priority = Moderate
I can't get it working.
Any help would be appreciated.
thank you
//var subString = email.subject.toLowerCase();
if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high")
current.u_priority = '1-Critical SLA ( 1hr)';
}
if (email.importance != undefined) {
if (subString.indexOf("urgent") <= 0 && email.importance.toLowerCase() != "high");
current.u_priority = '3-Moderate SLA (24hrs)';
}
if (subString.indexOf("urgent") >= 0 && email.importance.toLowerCase() != "high") {
current.u_priority = '1-Critical SLA ( 1hr)';
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-15-2022 12:19 PM
Hello,
In your script you've commented out the variable that's being set to the email.subject...so obviously you'd want to uncomment that so that it can be applied elsewhere.
For determining that the subject DOES NOT contain urgent...you'd want to use:
subString.indexOf("urgent") == -1
-1 is a result when what you're searching for is not found...
Otherwise, if urgent is found, it's going to == 0 or higher...
So determining that the subject DOES contain urgent, you'd use:
subString.indexOf("urgent") > -1
Please use logging statements, etc. for other pieces of your script to help you troubleshoot, but the above that I've mentioned should get you going in the right direction.
Also, for setting the priority...you'd want to ensure you're using the proper value, not display value. Please look at that field in the dictionary and then it's choice list and verify the "value" and use those.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-15-2022 12:19 PM
Hello,
In your script you've commented out the variable that's being set to the email.subject...so obviously you'd want to uncomment that so that it can be applied elsewhere.
For determining that the subject DOES NOT contain urgent...you'd want to use:
subString.indexOf("urgent") == -1
-1 is a result when what you're searching for is not found...
Otherwise, if urgent is found, it's going to == 0 or higher...
So determining that the subject DOES contain urgent, you'd use:
subString.indexOf("urgent") > -1
Please use logging statements, etc. for other pieces of your script to help you troubleshoot, but the above that I've mentioned should get you going in the right direction.
Also, for setting the priority...you'd want to ensure you're using the proper value, not display value. Please look at that field in the dictionary and then it's choice list and verify the "value" and use those.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-16-2022 08:45 AM
Thank you Allen,
I got it working!
Tricia