Issue with dates on an inbound email action

Alex Saager1
Tera Contributor

I'm trying to take a date from an inbound email and set that as a catalog variable which has a type of date but when I do this no matter what date I set in the email the variable always gets set as the current date.

 

The email contains Hire date: 01/07/2023 for example:

AlexSaager1_0-1687543791336.png

 

This is the inbound email action:

AlexSaager1_1-1687543845266.png

 

But this is the result I get:

AlexSaager1_2-1687543893763.png

 

Any suggestions on how best to take a date from an email and just have it populate on a date variable.

 

Kind regards,

 

Alex

 

 

 

 

 

 

 

6 REPLIES 6

@Alex Saager1 , then in that case , you need to  use basic string function and change the input hire date into system date format and then you can pass the changed formatted date into glide date time object. 

 

Or if feasible if you can change date format to input date format of hire date in inbound email. 

It will work then for you. 

 

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hi @Alex Saager1 ,

 

Hope you are doing great.

 

If input date in inbound email is in format mm/dd/yyyy and in your system date format is dd/mm/yyyy, then in that case you need to convert the input date into dd/mm/yyyy and then set value in cart variable.

 

please try using below code for conversion , it will work for you

var hire_date = email.body.hire_date.toString();

//script to convert from mm/dd/yyyy to  to dd/mm/yyyy
var dateParts= hire_date .split('/');
var hire_date_converted_format = dateParts[1]+'/'+dateParts[0]+'/'+dateParts[2];


cart.setVariable(item,'start_date',hire_date_converted_format );


// also make sure in below inbound script of your , make sure you have comment out your previous line where you have set start date direccty with hire date.

:

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma