The CreatorCon Call for Content is officially open! Get started here.

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

 

Ok think Im getting somewhere

 

Based on logs the date error or change from the date I selected to todays date happens after the GlideDate() then day.setValue(),  based on the info logs:

Info Logs

find_real_file.png

 

Script Includes

find_real_file.png

 

 

HI,

can you change this line:

Instead of day.setValue(firstDT);

 

try

var day = new GlideDate(firstDT);

 

Thanks,
Ashutosh

comes out blank again. This just doesn't want to work lol

@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 🙂

HI,

Nice. 

try using getNumericValue as well.

 

Thanks,

Ashutosh