how to check email.subject contains a partiular string in servicenow

SSA1
Giga Expert

Hi,

 

I have a issue when I am trying to find a particular string in email.subject so I have used following in the inbound email action but none of them worked.

 

if(email.subject.toLowerCase().indexOf("INC") > -1)

{

current.u_escalation_type='Incident';

}

AND this is another way I tried

var subject=email.subject.toLowerCase().toString();

if(subject=="INC")
        {
current.u_escalation_type='Incident';
        }

 

None of them worked. Please guide me how I can achieve this.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi,

if(email.subject.toLowerCase().indexOf("INC") > -1)

Should work. Can you apply logs & see if it goes in IF statement.

Something as below.

if(email.subject.toLowerCase().indexOf("INC") > -1)
{
gs.log('Inside if statement');
current.u_escalation_type='Incident';
}

View solution in original post

2 REPLIES 2

Jaspal Singh
Mega Patron
Mega Patron

Hi,

if(email.subject.toLowerCase().indexOf("INC") > -1)

Should work. Can you apply logs & see if it goes in IF statement.

Something as below.

if(email.subject.toLowerCase().indexOf("INC") > -1)
{
gs.log('Inside if statement');
current.u_escalation_type='Incident';
}

Namrata Ghorpad
Mega Sage
Mega Sage

Hello,

Try the below code.

if(email.subject.toLowerCase().indexOf("inc") > -1)

{

current.u_escalation_type='Incident';

}

OR

if(email.subject.contains("INC"))

{

current.u_escalation_type='Incident';

}

Thanks,

Namrata