g_form.setValue is not setting value in Date/time field for Onsubmit client script

peshwen
Giga Contributor

Hi All,

I have created one date/time field 'Date' which is read only. I have written one client script to populate the field with current date and time. For it i have used script include which will return current time using gs.nowDateTime(). I am using this because i want the Date field should be populated even if i hit 'Save' button on form and no changes are done to other fields on form.

While saving it is showing that field is populated with current date time...but after record is saved and form is loaded..Date field is blank..

Please help me   why it is happening like that...i want to save date field with date and time when i just hit 'save or update' button and make no changes to fields on form\

Thanks,

Nikhil

9 REPLIES 9

I tried but after hitting save form is getting hung and not proceding further


Then remove g_form.save(); and try again.


then also not working


The example at https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=client shows that you need to unwrap the response using something like this in your callback function.



function HelloWorldParse(response) {  
    var answer = response.responseXML.documentElement.getAttribute("answer");
    alert(answer);
}


ruzzty06
Tera Expert

What is the date field for?