Updating Work Notes with External User (Guest) Email Address via Inbound Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 11:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2024 11:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2024 10:23 AM
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:
email.user appears to be the same:
Unfortunately ServiceNow's recommendation of email.origemail is the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2024 11:17 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2024 12:25 PM
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.