How to set current date in the Date field?

Anusha Savanth
Tera Expert

Start date is a Date Field. It should populate current date only when the B choice is selected on the A field.

Please help me.

1 ACCEPTED SOLUTION

Anusha Savanth
Tera Expert

Write a ONCHANGE client script 

var currentDate = new Date().toISOString().split('T')[0];
g_form.setValue('start_date',currentDate);

View solution in original post

15 REPLIES 15

not working

try this 

javascript: new GlideDateTime().getDate();

no it is also not working

can you share screenshot?

 

Kartik Sethi
Tera Guru
Tera Guru

Hi @Anusha M 

 

Try the below-provided line in the default value:

javascript: gs.now()

Or if time is also required

javascript: gs.nowDateTime()

 

This should work!!


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik