Checking checkbox before closing task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 07:00 PM
hi. i have a list of checkbox below being displayed in Sc_TASK. how do i make a checking to ensure that all checkbox are checked before closing the task?
Note: the checkbox are variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 07:57 PM
you can use onSubmit normal client script on sc_task and check the variable value
function onSubmit() {
if (g_form.getValue('state').toString() == '3') {
// give the checkbox variable names here
var checkboxes = ['checkbox1', 'checkbox2', 'checkbox3', 'checkbox4', 'checkbox5', 'checkbox6'];
var allChecked = true;
checkboxes.forEach(function(checkbox) {
if (g_form.getValue('variables.' + checkbox).toString() != 'true') {
allChecked = false;
}
});
if (!allChecked) {
g_form.addErrorMessage('All checkboxes should be checked during closure');
return false;
}
}
}
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 08:22 PM
thanks, how do i ensure it only run for the specific task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 09:35 PM
you can check specific catalog task short description
function onSubmit() {
if (g_form.getValue('state').toString() == '3' && g_form.getValue('short_description') == 'your catalog task short description') {
// give the checkbox variable names here
var checkboxes = ['checkbox1', 'checkbox2', 'checkbox3', 'checkbox4', 'checkbox5', 'checkbox6'];
var allChecked = true;
checkboxes.forEach(function(checkbox) {
if (g_form.getValue('variables.' + checkbox).toString() != 'true') {
allChecked = false;
}
});
if (!allChecked) {
g_form.addErrorMessage('All checkboxes should be checked during closure');
return false;
}
}
}
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 10:09 PM
Did this work for you?
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-09-2025 09:16 AM
Hope you are doing good.
Did my reply answer your question?
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