Can I trim the start of an email via an inbound action?

dave_edgar
Mega Guru

So, I have a formatted email hitting our SNow instance which we rip some of the info out from to complete various fields BUT the last section of the email is a free text section from where is comes so it have carriage returns etc in it over multiple lines.

I need to get the system to either read the section and print it in the detailed description section OR trim the first part of the email and only give me the last section.   Is this possible, here is an example email body:

Submitted on Monday, 27 November, 2017 - 13:12

Title (Mr, Mrs, Dr, etc):Mr

First name:Joe

Last name:Blogss

Email address:jb@hotmail.com

Enquiry type:Product query

Additional information:

Hi,

I was just wondering if it is possible to have a latte waiting for me when i arrive on site.

Thanks,
Dave

We use sections 'Title (Mr, Mrs, Dr, etc):', 'First name:', 'Last name:', 'Email address:' & 'Enquiry type:' to complete various fields.

I need to make the detailed description whatever is after 'Additional Information:'

Can this be done

1 ACCEPTED SOLUTION

Here's the answer in-case anyone can find it useful, a find and replace:



var bodyText = email.body_text; // getting the text


if (!bodyText)


      bodyText = email.body_html;


var sample = bodyText; //putting it into a string


var substr = sample.substring(sample.indexOf('Additional information:'));   // replace everything before Additional information:


current.description = "Received from: " + email.origemail + "\n\n" + substr; // write it to the field


View solution in original post

2 REPLIES 2

Jaspal Singh
Mega Patron
Mega Patron

Hi Dave,



Did you try using something as below



current.comments = email.body.additional_comments; //considering the above format of mail.


gs.log('Additional comments are ',email.body.additional_comments);


Here's the answer in-case anyone can find it useful, a find and replace:



var bodyText = email.body_text; // getting the text


if (!bodyText)


      bodyText = email.body_html;


var sample = bodyText; //putting it into a string


var substr = sample.substring(sample.indexOf('Additional information:'));   // replace everything before Additional information:


current.description = "Received from: " + email.origemail + "\n\n" + substr; // write it to the field