- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 09:50 PM
Hi ALL,
I have a variable with Date Type and I want the variable to auto populate current date. I used onChange client script with below script but no date populated. Could you please help with a script to achieve this requirement. Thank you.
var dFormat = g_user_date_format;
var tdayDate = formatDate(new Date(),dFormat);
g_form.setValue('todayDate', tdayDate);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 09:55 PM
Hey Rich,
Go to variable dictionary (right click on the variable) and in default value write this: javascript:gs.nowDateTime()
If it works the please mark my answer Correct and Helpful.
Thanks and Regards:
Utpal Dutta

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 09:55 PM
Hey Rich,
Go to variable dictionary (right click on the variable) and in default value write this: javascript:gs.nowDateTime()
If it works the please mark my answer Correct and Helpful.
Thanks and Regards:
Utpal Dutta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 10:19 PM
Thanks Utpal. It worked for the date. Can you guide me with populatinge the "requestor's TITLE" to a single line text type? Usually there is a field on the user table called title with user's title info. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 10:35 PM
Hi,
for logged in user title you need to use this; in the default value of that variable
javascript: gs.getUser().getRecord().getValue('title');
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 10:45 PM
Hi. I tried this script but its not populating.