Inbound Action Script doesn't work from particular mailbox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2024 04:57 AM
Hi there,
I have an issue that is driving me crazy and I can't see where the issue might be. Basically, I have a script where an e-mail comes into ServiceNow and, using an Inbound Action, it removes the first e-mail from the e-mail body, checks the e-mail against the User table and, if there is a match, sets it as the Requested For. If not, it will put in a generic one. Here is my script...
// Grabs a list of e-mails from the body text of the e-mail
var pulledEmails = email.body_text.match(/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
var mainUserEmail = pulledEmails[0].toString();
// Checks the User table for the user who has the first of the e-mails listed
// (which will be who needs e-mail released)
var userRec = GlideRecord("sys_user");
userRec.addQuery("user_name", mainUserEmail);
userRec.query();
// If it finds a User record with that e-mail, it will store that info.
// If not, it will put the default user in.
if (userRec.next()) {
var emailUserID = userRec.sys_id.toString();
}
else {
var emailUserID = 'e0847fd2fb1382902b73f783aeefdcca';
This works if I send the e-mail in from several other mailboxes other than the one I need it to come from. It's pulling the e-mail address perfectly from the body text but when it goes to do the Query, it seems to be coming back with nothing as I keep getting my tickets assigned to the default user.
Is there a world where the e-mail text is in a format the Query can't read? I have no idea and I am clutching at straws at this point. Let me know if any of you have any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2024 06:32 AM
I checked which e-mail was being pulled from the body of the e-mail and it is definitely pulling the correct information from it. Sadly, when it then looks at that info against the User table, it says there isn't a match.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2024 12:55 AM
Did you change your query statement?
userRec.addQuery("email", mainUserEmail);
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2024 01:12 AM
We use the user's e-mail address as their username so it is the same information. It still didn't work when we did have it set to e-mail originally sadly.