- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:21 PM
I want to make a onchange client script When a user selects a category, automatically set a default subcategory using client scripts on incident table
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 04:28 AM
For this, you have to create Onchange Client script and set field name to category.
PS: At first, try every task on your own for better understanding and then if you stuck somewhere then we will definitely help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:25 PM
You can do something like this
Table: incident
Type: onChange
Field name: category
Script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Example: set default subcategory based on category
switch (newValue) {
case 'hardware':
g_form.setValue('subcategory', 'laptop');
break;
case 'software':
g_form.setValue('subcategory', 'email');
break;
case 'network':
g_form.setValue('subcategory', 'wifi');
break;
default:
g_form.setValue('subcategory', '');
}
}
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2025 11:17 PM
Yes this is helpful and worked perfectly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:29 PM
so what did you start with and where are you stuck?
It's an easy requirement.
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
07-13-2025 09:31 PM
I have recently started development course ,in that way i got this small task so i have asked in community