Updating Work Notes with External User (Guest) Email Address via Inbound Action

Maurice Murphy
Tera Guru

We have an inbound action through which users external to our platform are sending emails to a mailbox which then forwards to ServiceNow. We process these emails via the inbound action which generates a ticket for notification and reporting purposes. No other action is performed on the ticket itself, however the group actioning these tickets needs to be able to identify the user via their email.

 

As these are all almost exclusively from external users and we are currently unable to create new users for these individuals, they always show up as "Guest". I've tried several ways of pulling from the "User" field on sys_email, but to no avail. This has included both scripting within the inbound action itself:

// Note I have also tried this with email.origemail as well.
current.work_notes = "User's email: " + email.user.toString();
current.update();

as well as a script in a Flow that triggers when a record is produced on the scoped table.

// Create a new Glide Record for the Email table.
var sysEmail = new GlideRecord("sys_email");
// Query the email table for a record where the subject matches
// the triggering record's short description.
sysEmail.addQuery("subject", fd_data.trigger.current.short_description);
// Submit the query.
sysEmail.query();

// If a record is returned, perform the following actions.
if(sysEmail.next){
    // Create a new variable that stores the user's email as a string.
    var userEmail = sysEmail.user.toString();
    // Return the variable to the Work Notes field.
    return userEmail;
}

Is there any simple way for me to go about this that I am missing? Is there something wrong in either of those scripts? Any help is greatly appreciated.

5 REPLIES 5

ShubhamGarg
Kilo Sage

Hello @Maurice Murphy ,

Have you tried email.from instead of email.user? Can you try to print email.from?

That should work & fetch you the required value.

If my response helps you in any way, kindly mark this as Accepted Solution/Helpful and help in closing this thread.

Regards,

Shubham

I went ahead and threw together a fix script to try and test this out with a specific email record.

var email = new GlideRecord("sys_email");
email.addEncodedQuery("sys_idSTARTSWITH591768453394d250518ba3570e5c7b4e");
email.query();

if (email.next()){
	gs.info("@@@@@@@@@@@@@@@ User's email is the following: " + email.from());
}

This is the result of email.from:

MauriceMurphy_0-1724692659950.png

email.user appears to be the same:

MauriceMurphy_1-1724692904866.png

Unfortunately ServiceNow's recommendation of email.origemail is the same.

MauriceMurphy_2-1724692976696.png

 

There is no field on sys_email table with field 'from'.

email.from is only accessible by inbound email action. () should not be mentioned after email.from (like this - email.from())

Hope this helps.

 

If my response helps you in any way, kindly mark this as Accepted Solution/Helpful and help in closing this thread.

Regards,

Shubham

Ah, gotcha, this is actually incredibly helpful. Didn't realize the inbound action and the actual sys_email record itself had different relevant fields. I'm going to give both another try on the inbound action itself.