Inbound email action - call script include in condition

adam_webster
Kilo Contributor

Hi,

Im not able to include multiple email addresses in the condition field for the inbound email action script due to length.

I need some guidance on creating a script include and calling it in the inbound action condition.

script include:

function checkEmail(email) {
var e1 = email.receipients.toLowerCase().indexOf('****') >= 0;
var e2 = email.receipients.toLowerCase().indexOf('******') >= 0;
var e3 = email.receipients.toLowerCase().indexOf('*******') >= 0;
var e4 = email.receipients.toLowerCase().indexOf('*******') >= 0;
var e5 = email.receipients.toLowerCase().indexOf('**********') >= 0;


return e1 || e2 || e3 || e4 || e5;
}

Thanks,

 

A

7 REPLIES 7

Can you post your script here and a screenshot of your inbound action?


Please mark this response as correct or helpful if it assisted you with your question.

Hi

My script:

 

 

if (email.recipients.indexOf('***')>= 0 || email.recipients.indexOf('*****')>= 0 || email.recipients.indexOf('*****')>= 0 || email.recipients.indexOf('*****')>= 0 || email.recipients.indexOf('***')>= 0 )
{

gs.log('Ahmed Test ' + rec);

current.caller_id = "*****";
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.description = email.subject;
current.business_service = "d74e10dbdb7cc7004952fd431d96194b";
current.category = "Gateway issues";
current.assignment_group = "Service Desk Support";
current.impact = 3;
current.urgency = 3;
current.incident_state = IncidentState.NEW;
//current.notify = 2;
current.contact_type = "email";

if (email.body.assign != undefined)
current.assigned_to = email.body.assign;

if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high")
current.priority = 1;
}

if (email.body.priority != undefined)
current.priority = email.body.priority;

current.insert();
}

Baala T
Mega Guru

Adam,

Try the below script without setting any conditions in "When to Run".

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
	var aValidEmailIDs = ['a@test.com', 'b@test.com', 'c@test.com', 'd@test.com', 'e@test.com'];
	
	var sEmailIDs = email.getValue('recipents').toLowerCase();
	var bHasReceivedFromValidUsers = false;
	
	for(var i=0; i < aValidEmailIDs.length; i++){
		bHasReceivedFromValidUsers = bHasReceivedFromValidUsers || (sEmailIDs.indexOf(aValidEmailIDs[i]) != -1);
	}
	
	if (!bHasReceivedFromValidUsers) {
		logger.warn("This Email is not received from any of valid Users");
		return;
	}

	//your code
	


})(current, event, email, logger, classifier);