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

Hello @Maurice Murphy ,

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

Regards,

Shubham