g_form.removeOption() is not working on dependent field

prakhar_yadav
Tera Contributor

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');
    }

}

 

 

2 REPLIES 2

Jaspal Singh
Mega Patron
Mega Patron

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.

Satishkumar B
Giga Sage
Giga Sage

Hi @prakhar_yadav 

 

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."