cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pre-execution script - set future dates with api

elaineong
Newcomer

May I know what was wrong with the commented-out lines?

I am trying to set future dates using API, but it will not work.

 

//var curdate = new Date();
//var arriveDate = curdate.getTime() + 5 * 24 * 60 * 60 * 1000;
//var departDate = curdate.getTime() + 6 * 24 * 60 * 60 * 1000;


//api.setValue("arrriveDate", api.dateToFormat(arriveDate, "dd/MM/yyyy"));
//api.setValue("departDate", api.dateToFormat(departDate, "dd/MM/yyyy"));

 

// below works

api.setValue("arriveDate", "09/11/2021");
api.setValue("departDate", "10/11/2021");

1 REPLY 1

AK
Pro

@elaineong,

 

Nothing seems to be wrong with your lines. Can you try to use api.getValue like below to see the output.

api.setValue("arrriveDate", api.dateToFormat(arriveDate, "dd/MM/yyyy"));
api.info(api.getValue("arrriveDate"));

We have to use api.getValue() to get the value of the key previously set by api.setValue().

 

Regards,

AK

Featured Posts