g_form.removeOption() is not working on dependent field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 02:23 AM
Hi Community,
Client script with type "onchange" is not working for dependent field. The requirement is as soon as "Incident Name" will be "TEST" then, in the "Release Type" field "DEPLOYMENT" option should be removed.
Below is the code I am using, and I am using correct backend names of fields and options. And this is not working with the dependent fields, for any other fields, it's working fine.
Here, "Incident Name" and "Release Type" are dependent fields
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'test') {
g_form.removeOption('release_type', 'deployment');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 02:40 AM
Hi Prakhar,
Are you the value being compared in if comply with upper case/lower case? Try adding an alert to check the value in the newValue and compare that then in the if clause.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 02:47 AM
try this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue.toLowerCase() === 'test') { // Ensure case insensitivity
g_form.removeOption('release_type', 'deployment');
}
}
———————————————————-
If my response helps, please mark it as "Accept as Solution" and consider it "helpful."