Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

onchange client script reverse

gvramanarao
Tera Contributor

I'm writing client script -

my requirement is simple: if the category is 'software' then make 'description' field hidden. It is working fine, but I want to write reverse if, and I stuck there! When Im changing the category to some other, the description field is not visible. 

3 REPLIES 3

palanikumar
Giga Sage
Giga Sage

Hi,

I suggest you to use UI Policy for this

Condition = category = software

UI Policy Action:

Add entry for Description and set visible to true

 

Note: UI Policy will reverse automatically

 

If you are using Client Script, then it should be a onChange Client script on variable category.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (newValue == "software") {
        g_form.setVisible("description", false);
    } else {
        g_form.setVisible("description", true);
    }

}
Thank you,
Palani

Thank you

gvramanarao
Tera Contributor

Thanks @palanikumar