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

Hello,

If it helped, please mark it as solution.
Makes it easier for others to find it.

With regards
Anton

Done.Thank you!