We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Accessing email "from" value in Inbound email action to create IMS

GabrielCSSMI
Tera Contributor

I want to trigger an email action based on the value of the "from" email. It would not be an email from the sys_user table as the field provided for that seems to be based on. So I'm trying to do so via the action script.

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

	if(email.origemail == "sentFromEmailString") {
		current.opened_for = gs.getUserID();
		current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
		current.short_description = email.subject;

		current.type = "email";
		current.insert();
	} else {
		return false;
	}
})(current, event, email, logger, classifier);

It is not currently working that way. What would be the best way to achieve this?

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron

Hi Gabriel,

Try replacing

if(email.origemail == "sentFromEmailString") {

with

if(email.from.indexOf('sentFromEmailString')>-1) {

 

 

View solution in original post

2 REPLIES 2

Jaspal Singh
Mega Patron

Hi Gabriel,

Try replacing

if(email.origemail == "sentFromEmailString") {

with

if(email.from.indexOf('sentFromEmailString')>-1) {

 

 

GabrielCSSMI
Tera Contributor

This works thank you!