Hide Subtype field if there is no subtype for type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 05:48 AM
Hello All
Can you please help me on this requirement?
I want to hide the subtype field if there is no subtype is present in the sys_choice table related to particular Type.
Regards,
Alok Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 05:51 AM
Is subtype dependent on type?
If yes then I don't think you can hide it. You can use onChange on type and see if any choice is available for subtype by querying sys_choice table
If nothing then hide that field.
But why would there be no subtype for that type?
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
03-12-2025 01:03 PM
Yes subtype is dependent on type and we have many types where we don't have subtype value. so if subtype is not present why we can show the field its better to hide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 06:31 AM
If subtype doesn't exist for type then hide it
You know which type doesn't have sub-types simply have onChange on type and check the value and hide it
something like this but please enhance
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'ABC' || newValue == 'DEF') {
g_form.setDisplay('subtype', false);
} else {
g_form.setDisplay('subtype', true);
}
}
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
