- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 09:39 AM
Hi everyone,
I have an inbound email action active and I'm trying to add a few additional conditions, all consisting of checking if the email subject "does NOT start with xxx".
I've written the following script include to check it:
var emailSubject = Class.create();
emailSubject.prototype = Object.extendsObject(AbstractAjaxProcessor, {
doesNotStartWith: function() {
var subject = email.subject;
var subjectString = subject.toString();
if (!subjectString.startsWith('TEXT A')
&& !subjectString.startsWith('TEXT B')
&& !subjectString.startsWith('TEXT C')
&& !subjectString.startsWith('TEXT D')
&& !subjectString.startsWith('TEXT E')
&& !subjectString.startsWith('TEXT F')
&& !subjectString.startsWith('TEXT 1')
&& !subjectString.startsWith('TEXT 2')
&& !subjectString.startsWith('TEXT 3')
&& !subjectString.startsWith('TEXT 4')
&& !subjectString.startsWith('TEXT 5')) {
return true;
} else {
return false;
}
},
type: 'emailSubject'
});
I believe the logic is correct, as I've tested it outside Servicenow, however I'm not being able to call the script on the condition field inside the inbound email action:
Is there any way you could help me understand what I'm doing wrong?
Thanks in advance for your help.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 10:00 AM
Since, you are passing the parameter in the function, same way you have retrieve:
doesNotStartWith: function(emailSubject) {
var subject = emailSubject;
Replace those two lines in your script inlcude, it should work just fine
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 10:00 AM
Since, you are passing the parameter in the function, same way you have retrieve:
doesNotStartWith: function(emailSubject) {
var subject = emailSubject;
Replace those two lines in your script inlcude, it should work just fine
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 07:11 AM
Thank you Aman, that solved the problem!
Best regards.