Inbound Email Action: Setting Field Values from the Email Body where name has a space

jmoreau
Mega Contributor

I am using an inbound action to parse the body of the email.   I have done this fine for strings and where the name of the name/value pair is one word.   However, I am unable to figure out how to parse it when the name is separated by a space.

Two questions:

1) How to parse where name has spaces?

2) How to insert into a Date type field?

Email Example
<Body>

Pricing Effective: 04/11/2017

</Body>

Inbound Action Script

current.u_my_custom_date_field = email.body."Pricing Effective";

1 ACCEPTED SOLUTION

Ignore the previous one.


The Date format should be same as system date format



var mydate = email.body_text.indexOf('Pricing Effective: ');


var gDate = new GlideDate();


gDate.setValue(mydate);


gs.info(gDate);



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

10 REPLIES 10

SanjivMeher
Kilo Patron
Kilo Patron

Hi Jeffrey,



You can use



current.u_my_custom_date_field = email.body_text.indexOf('Pricing Effective: ');



Please mark this response as correct or helpful if it assisted you with your question.

Thank you!     Do you know if I have to do anything specific to make this a date.   If the field was created as a "Date" type, do I need to transform the string value or will it automatically translate that for me.


You will have to convert it to date. Try if below works.



var mydate = email.body_text.indexOf('Pricing Effective: ');



current.u_my_custom_date_field = new GlideDate(mydate);



Please mark this response as correct or helpful if it assisted you with your question.

Ignore the previous one.


The Date format should be same as system date format



var mydate = email.body_text.indexOf('Pricing Effective: ');


var gDate = new GlideDate();


gDate.setValue(mydate);


gs.info(gDate);



Please mark this response as correct or helpful if it assisted you with your question.