GlideAjax to Add date time is adding to today's date not the date field provided

Markell
Tera Guru

Hi Guys

I utilised the Glide Ajax provided by user @MB to add eg 1 year to a date field in a catalog Item.

The link to @MB Post: Client Script Date/Time Functions

The Client Script I utilised:

find_real_file.png

the Script Include to go with it is a big one so I copied and pasted the section used for the above ajax:

find_real_file.png

FYI for my own function to work I had to do a GlideAjax before hand to bring back another field integer. So the reply var is simply getting an integer that I use in the add time var. I point this out only for clarification of any differences with @MB Script.

find_real_file.png

 

Now what happens when I run this is that instead of taking the date from the proposed start date field, it seems to take today's date and then run the GlideAjax (correctly) based on that:

find_real_file.png

I cant really find anything on why this would take place. All sources seem to suggest g_form.getValue() should work for a Date field, but I'm certain this is where this is going wrong. It's as though it doesn't recognize the field.

Any suggestions?

 

 

Kind Regards

 

 

Markell

 

1 ACCEPTED SOLUTION

@Ashutosh Munot DONE IT!

day.setDisplayValue();

find_real_file.png

 

NNot sure why I also had to do day.setValue() for it to work but hay 🤷

 

TThanks for trying anyway 🙂

View solution in original post

19 REPLIES 19

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

What is in reply. Seconds, min, days, numeric value?

Thanks,
Ashutosh

Its an Integer from a table. I know the integer works as it adds that number of years. 

i.e if you look at the Expiry date, A year has been correctly added but its to todays date

asifnoor
Kilo Patron

Hi,

 

You need to use GlideDateTime object.

var day = new GlideDateTime(firstDT);

Also, print firstDT and check if its displaying correct date or not.

 

Thanks for responding.

 

I made the change as suggested but this now brings back no value:

find_real_file.png