- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm trying to get an onChange client script to examine a group of fields and if ANY of them is blank (have them setup to auto-fill from a table), then I want a checkbox to evaluate to true. Here's what I have but it is not working. Any help/pointers are appreciated (I'm not an expert client scripter). Note, using the commented out else doesn't help either.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var needsUpdate =
!g_form.getValue('life_cycle_stage_as') ||
!g_form.getValue('life_cycle_stage_status_as') ||
!g_form.getValue('business_service_tier_as') ||
!g_form.getValue('change_group_as') ||
!g_form.getValue('support_group_as') ||
!g_form.getValue('business_contact_as') ||
!g_form.getValue('managed_by_as') ||
!g_form.getValue('description_as') ||
!g_form.getValue('data_classification_as') ||
!g_form.getValue('regulatory_attribute_as') ||
!g_form.getValue('vendor_as') ||
!g_form.getValue('installed_as');
g_form.setValue('record_needs_updating', needsUpdate);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var needsUpdate =
!g_form.getValue('life_cycle_stage_as') ||
!g_form.getValue('life_cycle_stage_status_as') ||
!g_form.getValue('business_service_tier_as') ||
!g_form.getValue('change_group_as') ||
!g_form.getValue('support_group_as') ||
!g_form.getValue('business_contact_as') ||
!g_form.getValue('managed_by_as') ||
!g_form.getValue('description_as') ||
!g_form.getValue('data_classification_as') ||
!g_form.getValue('regulatory_attribute_as') ||
!g_form.getValue('vendor_as') ||
!g_form.getValue('installed_as');
g_form.setValue('record_needs_updating', needsUpdate);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi Ankur, I went with UI policies instead but I believe your solution would have worked. I found a mis-matched variable type that was causing the issues. I didn't test your solution, but I will mark it as accepted.
