Retrieving Email Body variables for population in Catalog Items

EricG
Kilo Sage

I've never used the email.body.VARIABLE feature in Inbound Rules before.

The documentation from SNOW on this seems really straight forward.

I have a variable in the email called My_Department_Number:2069 on a single line.

I've tried using the suggest method for pulling the data out.

var myVari = "";

if (email.body.My_Department_Number!=undefined){
        myVari=email.body.My_Department_Number.toString();
 }

Nothing happens.   I've tried even just using the var myVari = "" and myVari =... as two lines only.

This gives me a log entry that shows myVari is undefined.

If I hard code the ticket variable i'm attempting to populate, the inbound rules works fine.

What did i miss? 

1 ACCEPTED SOLUTION

Try below

var splitext=email.body_text;

var splittoget=splitext.split('My_Department_Number:')[1];

var splittogetfinal=splittoget.split(' ')[0]; //This will give final result

View solution in original post

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Can you directly try below instead of checking if

    var myVari=email.body.My_Department_Number.toString();

 

If it still does not you can try something as below

var splitext=email.body_text;

var splittoget=splitext.split('My_Department_Number:')[1]; //this should give you the final value

OK, the second worked ok..

but the gs.log I have shows value I was wanting, however, it included everything after that number.

e.g. Thank You!  Privacy Verbiage, etc....

Try below

var splitext=email.body_text;

var splittoget=splitext.split('My_Department_Number:')[1];

var splittogetfinal=splittoget.split(' ')[0]; //This will give final result

Thanks for the help.

Also found that the variable was set incorrectly.

It had a space between the name: value.

 

once it was set to name:value  all went well.