when we select Check box it gives alert mesaage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 05:17 AM
i have requirement, in incident form i have checkbox field and another field is a date type field, whenever we click that checkbox field it will show alert message with "yes or no" options, if we select the 'yes' option then in the date field it will auto populate with the current date and if we select 'no' option then the checkbox field will false, how can i achieve this. Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 05:29 AM
You can use a client script or scripted ui policy to show a message when the checkbox is true.
And you can use a client script to set the current date if field changes to 'yes' and clear it if it's 'no'.
One note, though, since you are using a checkbox, there isn't really a 'yes/no' option, because it's true/false and if not clicked, it returns false. So, depending on your exact requirement, you only have to create logic on 'true'.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 05:47 AM
Hi @yaswanth
You can use "Confirm box". Based on the user response it'll proceed further.
Note: If you are using OOB Confirm box, then user needs to click either "Ok" or "Cancel". You cannot edit the confirm box button names. PFB the sample code.
On Change client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'true') {
var answer = confirm("Click OK to proceed with current date");
if (!answer) {
g_form.clearValue("u_boolean_1");
} else {
g_form.setValue("u_date", formatDate(new Date(), g_user_date_time_format));
}
}
}
Output:
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 06:31 AM
you can show confirm javascript prompt
then auto populate with current date
Check script shared by @J Siva
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader