- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 12:44 AM
Hi,
i've created a client script to set date on one of the form field. When i tested in the new project workspace it is not taking any effect. Could someone provide step-by-step guide on how to achieve this.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 06:01 AM
Try this script
function onLoad() {
//Type appropriate comment here, and begin script below
var currentDate=new Date();
var currentDateFormated = formatDate(currentDate, g_user_date_format);
g_form.setValue('field_name', currentDateFormated);
}
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 06:01 AM
Try this script
function onLoad() {
//Type appropriate comment here, and begin script below
var currentDate=new Date();
var currentDateFormated = formatDate(currentDate, g_user_date_format);
g_form.setValue('field_name', currentDateFormated);
}
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 07:50 AM
Hi @PatriciaA987250 ,
You can use below script to set the current date.
var today_date = new Date();
var today_date_time_str = formatDate(today_date, g_user_date_time_format);
g_form.setValue('your_field_name',today_date_time_str);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------