Inbound Email Action filter: Subject does NOT start with

Carlos52
Tera Expert

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:

find_real_file.png

Is there any way you could help me understand what I'm doing wrong?

Thanks in advance for your help.

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

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

Best Regards
Aman Kumar

View solution in original post

2 REPLIES 2

Aman Kumar S
Kilo Patron

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

Best Regards
Aman Kumar

Thank you Aman, that solved the problem!

 

Best regards.