Multiple inbound action

nidhinotra
Mega Contributor

Can i have multiple inbound action for a same email? I have actually created by giving different order but it created the same incident twice.

1 ACCEPTED SOLUTION

It will not add information to the same Incident. I missunderstood your first question I'm afraid.

Have you tried building the inbound script using functions inside the script? That may help you sorting out that it fills in different fields after each other.

If I understand your previous explanation, the information about customer is in the body and the rest is the normal email information?

I did this for a particularily unsorted email; I made a function in the script that made all parts of the body into different parts of an array and then added then where needed.

Yes, you can use the find variable function for inbound, but I like to know what I am getting.


(function (email, current) {
	var sender = getContent(email.body_text);
	var send = sentFrom(sender[0]);
	send = send.split(',');
	current.user = send[0];
	current.from = sender[0];
	if (send[1] != '') {
		current.mail_address = send[1];
	}
	current.assignment_group = 'predefined sys_id';
	var myQ = qAbout(sender[2]);
	var myPlace = getPlace(sender[3]);
	current.short_description = email.subject;
	var bodyDesc = 'Description: ' + sender[1];
	if (myQ == '') {
		bodyDesc = bodyDesc + '\n\nMissing var3: ' + sender[2];
	} else {
		current.var3 = myQ;
	}
	if (myPlace == '') {
		bodyDesc = bodyDesc + '\n\nMissing var4: ' + sender[3];
	} else {
		current.var4 = myPlace;
	}
	current.description = bodyDesc;
	current.insert();
})(email, current);

function getContent(body) {
	body = body.toString();
	var content = [];
	var var1 = body.indexOf('Variable 1');
	var var2 = body.indexOf('Variable 2');
	var var3 = body.indexOf('Variable 3');
	var var4 = body.indexOf('Variable 4');
	content.push(contentPush(body, var1, var2));
	content.push(contentPush(body, var2, var3));
	content.push(contentPush(body, var3, var4));
	var4 = var4 + 4;
	content.push(body.substr(bibliotek));
	return content;
}
function contentPush(body, start, end) {
	start = start + 4;
	end = end - 1;
	return body.substring(start, end);
}
function sentFrom(mail) {
	var username = regex to find a username;
	if (mail.match(username)) {
		var at = mail.indexOf(a string);
		var id = mail.substring(0, at);
		var account = new GlideRecord('sys_user');
		account.get('user_name', id);
		return account.sys_id + ',' + account.email;
	} else {
		var user = new GlideRecord('sys_user');
		user.addQuery('email', mail);
		user.query();
		if (user.next()) {
			return user.sys_id + ',' + '';
		} else {
			return 'sys_id of a generic account' + ',' + mail;
		}
	}
}
function qAbout(variable) {
	var id = new GlideRecord(referenced table);
	id.addQuery('name', variable);
	id.query();
	if (id.next()) {
		return id.sys_id;
	} else {
		return '';
	}
}
function getPlace(variable) {
	var placeID = new GlideRecord(referenced table);
	id.addQuery('name', variable);
	id.query();
	if (id.next()) {
		return id.sys_id;
	} else {
		return '';
	}
}

View solution in original post

11 REPLIES 11

SNOW User8
Giga Guru

No, You can not have multiple inbound action for a same email

It should create duplicates.

May I know the actual requirement?

nidhinotra
Mega Contributor

I have to pre-populate the incident fields at time of creation(category,subcategory,product and location) based on subject and caller id. And at the same time customer name based on description.If i put this all in one script.So, the moment it satisfy first condition it will not move ahead with rest.So, as a result either i will be able to autofill first or last.

felladin
Tera Guru

Hello,

Yes, you can have multiple actions that will handle an email. To only have one handle it, you mark "Stop processing" on a rule, which will prevent further actions.

We do this and set different order, which means, if a low order inbound actions will not hanlde an email, it moves on to the next and tries until it is finally handled.

I also recommend you install the Email Filters plugin, as it is very good!

With regards
Anton Vettefyr

But i want two inbound action for a single email as both have different purpose.So, what i want is that it should not create duplicate but 1st inbound action is to define my customer name field based on description and then it run second one to fill rest of the field based on the conditions given.