Inbound action getting skipped

Maria DeLaCruz
Tera Guru

Hello,

Need some help with an Inbound action.   I have a catalog item that asks for an email address.   A notification is sent to that email, and there's an "I Agree" link on that notification, and when they click that, it emails the instance that the user has agreed to the terms of use, etc, then a field gets updated on the RITM record.   However, I noticed that if someone enters an email address (which is not the one on their user profile) that has upper-case letters, the inbound action gets skipped.   Below is my inbound action.   I've tried to add .toLowerCase() after the variable, but that didn't help.

function validUser() {

if (current.request.requested_for == email.from_sys_id || current.variables.u_sra_email.toLowerCase() == email.from || current.variables.u_webmail_email.toLowerCase() == email.from)

  return true;

}

if (validUser()){

  if (email.subject.indexOf('I Agree') >= 0)

  current.u_sra_agreement = 'I Agree';

  if (email.subject.indexOf('I Disagree') >= 0)

  current.u_sra_agreement = 'I Disagree';

  }

  current.update();

Please help.   Thanks!

Maria

1 ACCEPTED SOLUTION

Hi Maria



Assuming your code is returning false from validUser() function...



Can you please put this in your 2nd IF loop in validUser() function (assuming that is the one expected to return TRUE, otherwise update it where ever is necessary)



var r = new RegExp(current.variables.u_sra_email, "i");


return r.test(email.from);


View solution in original post

20 REPLIES 20

Thank you Maria. Interesting. It's as if the inbound action doesn't know about the variables for that request item. I'm out of ideas at the moment. If nobody else comes up with something, reach out to support. I'll be interested to hear what they have to say.



HI Service Portal - ServiceNow


Contact Support | ServiceNow


Hi Maria



Can you try to log current.variables.u_sra_email without toLowerCase just to make sure this contains the actual value or not..


Also, can you please add some kind of log as indication in each IF loop in your ValidUser() function so that we will come to know which IF is returning true and it helps in debugging..


Hi Kumar,



Thanks for the response.   So, I've removed .toLowerCase, and this is what the Script Log Statements show:



find_real_file.png



I need the inbound action to not be case-sensitive when determining if the sender of the email is a valid sender.



Thanks,
Maria


Hi Maria



Assuming your code is returning false from validUser() function...



Can you please put this in your 2nd IF loop in validUser() function (assuming that is the one expected to return TRUE, otherwise update it where ever is necessary)



var r = new RegExp(current.variables.u_sra_email, "i");


return r.test(email.from);


Hi Kumar!



This worked perfectly!   Thanks so much!



Maria