I want to set today's date field automatically , when i opened the new form and same as with time so i have created two seperate fields for date and time those are need to be filled automatically when i open the new form could any one please help me.

suryapulletikur
Kilo Contributor

I want to set today's date field automatically , when i opened the new form and same as with time so i have created two seperate fields for date and time those are need to be filled automatically when i open the new form could any one please help me....?

1 ACCEPTED SOLUTION

rambo1
Tera Guru

If you want to use current time and date on different tables, the use this script include:

var MyDateTimeAjax = Class.create(); 
MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor,
{
nowDateTime: function ()
{
return gs.nowDateTime(); }
});

call this S.I in onload client script:
var ajax = new GlideAjax('MyDateTimeAjax'); 
ajax.addParam('sysparm_name', 'nowDateTime');
ajax.getXML(function ()
{
g_form.setValue('put your field name here', ajax.getAnswer());
});

View solution in original post

26 REPLIES 26

No Time field i kept glide time type only



find_real_file.png


Thank you. I made my glide_time field read-only (at the dictionary level) and found that the client script could not set it either. The workaround I had was to make the field editable (uncheck Read-only on the field's dictionary entry) and use the client script to set it to read-only after the value was set like this:



function onLoad() {


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


                  g_form.setValue('start_date', g_scratchpad.start_date);


        }



        if (g_form.getValue('start_time') == '00:00:00') {


                  g_form.setValue('start_time', g_scratchpad.start_time);


        }



        g_form.setReadOnly('start_time', true);


}



If the Read only field on the dictionary is already unchecked, then check our ACLs to provide write access to that field. That's the only way the client script is going to be able to write a value there is if the field is editable.


Ya now it is working Once Again Thank you and thank you for your patience Chuck Tomasi


You are welcome.



In the spirit of community... please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you


rambo1
Tera Guru

try display business rule:

current.your specified field = gs.nowDateTime();