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

Markell
Tera Guru

If found the issue.

 

g_form.getValue() doesnt get a value for the date field. I just did this onChange script for the proposed date field and it comes back blank:

find_real_file.png

 

So what I need is a way to get that value. Ill look in the SN Docs but so far no luck

Hi,

I did this and it worked for me. The value is retrieved properly for me.

Are you testing this on onChange script?


Thanks,
Ashutosh

Yes onChange script. I'm going to see if I create a new date field and try it what happens. I have had weird instances in the past where I have had like a faulty field for want of a better term.

Tried it again same problem 😞

FYI I was using newValue only works with the actual field value.

 

Still trying to get back date with the value from the field. Attempted converting to string (toString()) no luck