Inbound Action Update a reference field from email body
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 12:45 PM
I have requirements to create a project record once an @mention email is kicked out from smart sheets to a distro email which kicks off an inbound email action.
I can get the project record created however i'm trying to update a required reference field based on a value from the email body (location)
The number in the email would be the same as the location record however i can't seem to seperate and carry that email value to any field regardless of field type. I've tried a handful of various script lines with no success.
If anyone could please assist. I'd appreciate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 01:44 PM - edited 09-11-2023 01:44 PM
Hi, unfortunately post requirements are not clear form your post\partial screenshots, but I suspect you need to use string methods to extract the id from your email body and then a glidequery to lookup the record. Perhaps something like this
//for testing
var email = {};
email.body_text = 'DFGHJJ\ndgfhfghf\nRow 155:T3231\nhgfhfjhgjh\nddhd';
//find the start index
var startIndex = email.body_text.indexOf('Row 155');
find the end of the 'Row'
var endIndex = email.body_text.indexOf('\n', startIndex);
gs.info(startIndex);
gs.info(endIndex);
//find the ID
var myId = email.body_text.substring(startIndex + 8, endIndex)
gs.info(myId);
//lookup the ID and if found map it's sys_id to yourt reference field.
var recordCheck = new GlideRecord('targetTable');
if(recordCheck.get('yourIDField', myId)) {
current.yourReferenceField = recordCheck.sys_id;
}