Inbound Action Condition to call Script Include function

SNowUser11
Kilo Guru

Hi Experts,

I want to add extra condition to check in my inbound action whether the email subject contains INCIDENT or not . There are many places where I need to check this so thought of putting it in script include and calling it in condition but it is not executing SI . SI has prototype. 

Want to execute when email subject does not contains any INCIDENT

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

Have you validated that the SI is being called?

Also your script is incorrect. you're passing email.subject as the email variable however you're then doing:

var str = email.subject.toString();

This is effectively

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

 

change it to var str = email.toString();

View solution in original post

14 REPLIES 14

Hi Anson,

Already the SI has the function which is getting the incident (incnum) in my original question snap shot but sorry did not get do i need another separate function ? coz i just need the value which is in variable incnum

Thanks

Did you use this line in your function and returned the variable a?

var a = regex.match(email.subject.toString())[0];

You will need a separate function as your current one is only setup to return true or null. 

 

Or you can modify the existing function to: 

checkEmailSubjectForIncident: function(email){
	
	var regex = new SNC.Regex('/INC\\d{7}/im');
	var incnum = regex.match(email.toString());
	if(incnum[0]){
		return incnum[0];
	}
}

As this returns a value (truthy) it'll work for the condition and within your script.

how to validate if script include is being called by the inbound action? how to check if the parameter is being passed to the script include?

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Add logs in your Script include to check if the code is getting there.

Add multiple logs to see till where the code is getting and at which point is it failing. RegEx is always a slippery slope

-Anurag

-Anurag