Time gets saved as 00:00:00 in date/time field

Ankita3
Mega Expert

Hello guys,

Can anyone please help??!!

We have this field on our instance "contact_date" which is date/time field which captures the current date and time (client scripts are designed for the same)once the choice is selected from the drop down field (u_contact_sucessfull).

Now the issue is:

1. I select the option from the drop down (e.g. Phone)

2. Contact date gets populated (form is not yet saved)

3. save the form.

4. check the field if the date and time is properly captured, but Date stays and times turns 00:00:00.

Script to populate the time and date is as:

**** onChange Client script ****

if (g_form.getValue('u_contact_date') == '') {

    var d =new Date();

                  var navigator=window.navigator.appName;

                  if (navigator == 'Microsoft Internet Explorer') {

                      // var d =new Date();

  var now = gr.nowDateTime();

                        var day = d.getDate();

                        var month = d.getMonth() + 1;

                        var year = d.getFullYear();

                        //g_form.setValue('u_contact_date', day+"-"+month+"-"+year +" "+d.toLocaleTimeString());

    g_form.setValue('u_contact_date', now);

                  } else {

          var strDate = replaceAll(d.toLocaleString(),'/', '-');

        g_form.setValue('u_contact_date', strDate);

                  }

    }

   

function replaceAll(txt, replace, with_this) {

  return txt.replace(new RegExp(replace, 'g'),with_this);

}

Can anyone please suggest what's going wrong.? Help is much appreciated.!!

Ankita.

10 REPLIES 10

Chuck Tomasi
Tera Patron

The line that says:



var now = gr.nowDateTime();



Isn't going to work. gr is an unknown object. You may see this in your Browser debug/developer window in the error messages. It's likely part of the cause. I suspect you were after gs.nowDateTime(), which is a server side method and this is all about the client side. Was your line



var d = new Date();



not working also?


"now" was something I was trying with, but it didn't go well I assume. please find the accurate code below.


Abhinay Erra
Giga Sage

Ankita,



      nowDateTime() is the method of glide system.   Replace the line "   var now = gr.nowDateTime();" with "var now = gs.nowDateTime();".





Thanks,


Abhinay




PS: Hit like, Helpful or Correct depending on the impact of the response


"now" was something I was trying with, but it didn't go well I assume. code is re-pasted .