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

Thank you chuck Tomasi.


You are welcome.


If I have answered your question, 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


sorry even i tired the same but it's not reflecting in the form with values


Can you show me the complete details of your business rule and client script? Something is different between our two solutions. Mine worked fine so I'd like to see if there are any differences.


Business Rule


Same thing what you have suggested to me i tried that code with my field name....: g_scratchpad.u_time = new GlideTime().getDisplayValue();


Action : before


Inset ( selected )


Script : g_scratchpad.u_time = new GlideTime().getDisplayValue();