variable set fields

nameisnani
Mega Sage

Hi Team ,

 

Need help , 

 

The ' Short description ' and ' Description ' , are coming from variable Set .

 

And I want to make this variables not visible , when ever the [ Request category = production access to scdass ] 

 

nameisnani_1-1710134346733.png

 

Please provide me Client Script . 

 

NOTE - Please give Cilent Script only instead of UI plocy . Why because  there are some confusion's in UI Plociy . 

 

Please give Cilent script :

 

When ever user selects " Request category = production access to scdass "  >>>> short desp and desp , has to be not visible . 

 

Please give Cilent script :

26 REPLIES 26

Shruti
Mega Sage
Mega Sage

Hi @nameisnani ,

Create onChange client script on request category variable

Make sure Mandatory checkbox is unchecked for both variables (description and short decription)

Shruti_0-1710138424317.png

 

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

    if (oldValue != newValue) {
        g_form.clearValue('description'); //Replace description variable name
        g_form.clearValue('short_description'); //Replace short description variable name
    }
    if (newValue == "production access to scdass") //Replace choice value
    {
        g_form.setMandatory('description', false); //Replace description variable name
        g_form.setMandatory('short_description', false); //Replace short description variable name
        g_form.setDisplay('description', false); //Replace description variable name
        g_form.setDisplay('short_description', false); //Replace short description variable name


    } else {
        g_form.setMandatory('description', true); //Replace description variable name
        g_form.setMandatory('short_description', true); //Replace short description variable name
        g_form.setDisplay('description', true); //Replace description variable name
        g_form.setDisplay('short_description', true); //Replace short description variable name
    }

}

Service_RNow
Mega Sage

Hi @nameisnani 

You should try using ui policy.

If you still want to use client script, then the reason why the field is not getting hidden is because its mandatory. Make non-mandatory before hiding(do it for fields you want to hide).

Variable name - Request category

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {

return;

}

if (newValue == 'production access to scdass') {

g_form.setDisplay('short desp',false);
g_form.setDisplay('desp',false);

}
}

ON client script & Check the checkboxes to run on Requested Items & on Task level

RamSingh_1-1710136417245.png

 

 

 

Please mark reply as Helpful/Correct, if applicable. Thanks!

dgarad
Giga Sage

Hi @nameisnani 

 

refer to the below screen shot.

 

dgarad_0-1710137082295.png

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

In the single quote ' ' we need to pass value right ,

not the name.