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

It's supposed to be a Display business rule, not a Before.



Did you do the onLoad client script as well? It's a two part solution.


find_real_file.png


find_real_file.png


find_real_file.png



find_real_file.png


Yes Of course i did the both


Client Script :-


find_real_file.png



Business Rule :-



find_real_file.png


And Final Form :-


find_real_file.png


It was showing Undefined...?


OK, I think I see.



Q1: Do you want to set Start date and End date or just one?



Q2: Are those fields date or date/time fields?



Issue1: Your business rule is setting g_scratchpad.u_today_date, but the client script is setting the value using u_start_date (undefined.)


Ya Thank you for that now date is working but what about time can you suggest ...?


Time looks like a string to me. Please right click on the field and show me the contents of the popup that appears. It should look the same as this (with the exception of the field name.)



find_real_file.png



find_real_file.png