Pulling email body text into fields on a form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I've been doing some digging and trying to find an answer to this - I've found various different questions/articles that are marked as correct and working. However, they do not work for me as I get an error when trying to create the record stating 'Error: "email" is not defind.,Detail: "email" is not defined.
Here are the two methods I've found that are 'correct' but fail -:
var splitext=email.body_text;
var splittoget=splitext.split('My_Department_Number:')[1];
var splittogetfinal=splittoget.split(' ')[0]; //This will give final result
var bodyis=email.body_text; //gives you complete body of email var alerttext=bodyis.split('Alert Level:')[1]; //This gives you text after Alert Level var gettext=alerttext.split('HostName:')[0];//this gives the text before HostName
Neither work and throw the same error. Is something else required before this script to define email?
For reference, this is intended to be an Inbound Email trigger on a flow, which creates a record and will populate various fields based on what is put on the email. There will be multiple fields to populate, and we want to split each field out from the email, which I assume using the above options for script would work.
Obviously, I'm changing the details in the above to be the field on the email in question, before anybody asks if I changed them 😄
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you are writing this in inbound action?
did you add gs.info() and log the email body?
share screenshots
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
36m ago
oh you are using flow, then it won't work there directly.
the way to access body in flow is this
Easiest way to Trigger Catalog Item Request via Inbound Email
also check this
How to read body text in Inbound EMAIL Flow
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
30m ago - last edited 29m ago
Hi @StewartFletcher ,
This is not an inbound action script, so cannot access email object directly.
Use the below code to access email_body.
var body = fd_data.trigger.body_text;
Also, remember to return your value.
Thanks
Anand