Unable to hide one field on Catalog item form

deepikagang
Tera Contributor

Hi All,

There is one field with multiple options , It should not visible by default when form loads, It should only visible when someone selects "yes" as an option on another field.

deepikagang_0-1738594926071.png

I have tried creating Catalog UI policy and catalog Client script but still still it is showing by default on the form.

 

Thank you in advance for your help!

 

Thank you

Deepika 

12 REPLIES 12

Hi @Runjay Patel ,

I tried but not working.

 

Thanks

Deepika

Hi @deepikagang ,

 

If you wanted to hide the choice option then you can write a one load client script like below.

function onLoad() {
    // Remove multiple choices by repeating this line for each option you want to remove
    g_form.removeOption('variable_name', 'choice_value_1'); // Remove first option
    g_form.removeOption('variable_name', 'choice_value_2'); // Remove second option
    g_form.removeOption('variable_name', 'choice_value_3'); // Remove third option
    // Continue adding lines for other choices you want to remove
}

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Ankur Bawiskar
Tera Patron
Tera Patron

@deepikagang 

you will have to use onLoad catalog client script to remove that option

g_form.removeOption('variableName', 'choiceValue');

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar ,
Thank you for your response!

There are multiple choices in this field, should I mention all of them?


Thank you

Deepika

@deepikagang 

yes you can repeat that line for removing those many options

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader