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

Hi,

Is this onchange of that same field?


Thanks,
Ashutosh

find_real_file.png

When i do

alert(newValue);

find_real_file.png

 

This is bringing back today's date? I'm using another date field to bring back a day 1 year in the future of that date.

 

e.g I pick 31/07/2020 in my first date field (Proposed Start Date), In my second date field (expiry date) I expect to get back 31/07/2021

find_real_file.png

 

 

 

the alert you showed in your screenshot is for which field? It is from callback of script include or somewhere else?

Thanks,
Ashutosh

Hi Ashutosh

The callback was simply an alert() onchange script based on the Proposed start date field. 

Using this I gathered that I do get a value back using g_form.getValue() if I used the field value 'proposed_start_date' rather than newValue. 

I did this simply to see if there was an issue in getting the value initially.

I know by doing this there is a value that is captured, I now need to check if it is passed to the script include and I will try to gs.info the script by each line to see where the break is