How to get a Text box when a checkbox is selected in a service catalog

Gowtham Kodali
Tera Contributor

Hi 

 

I have a requirement to get a Text box displayed  when an Checkbox is selected how can i achieve this in service catalog 

 

T

 

1 ACCEPTED SOLUTION

Dhananjay Pawar
Kilo Sage

Hi Gowtham,

You can use no code solution for this

Create catalog UI policy and add condition like.

checkbox variable is true

under UI policy action you can show other text box variable by setting visibility to true.

Thanks,

Dhananjay.

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Gowtham,

you can create onLoad catalog client script which applies to RITM and sample script below

UI Type -  ALL

function onLoad(){

if(g_form.getValue('checkbox1variable') == false){

g_form.setDisplay('checkbox1variable', true);

}

}

please check below blog which says how to achieve this

Hide empty variables on RITM and TASK record

Regards
Ankur

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

Dhananjay Pawar
Kilo Sage

Hi Gowtham,

You can use no code solution for this

Create catalog UI policy and add condition like.

checkbox variable is true

under UI policy action you can show other text box variable by setting visibility to true.

Thanks,

Dhananjay.

Dhananjay Pawar
Kilo Sage

You can also use onChange catalog client script on checkbox variable.

 

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

if(g_form.getValue('variable name')==true){ // enter correct variable name

g_form.setVisible('text box variable',true); // enter correct variable name

}

else{

g_form.setVisible('text box variable',false); // enter correct variable name

}

}

sriram35
Kilo Guru

Hi Gowtham,

 

you can achieve this by using UI policy or Client Script. I think the best way is UI Policy.

Please follow the below steps:

1. Create Variables under the catalog item.

2. create a Catalog UI policy.

3. click on new

4. In condition select checkbox(your variable) is true

find_real_file.png

 

5. In Catalog UI policy Action you need to select Textbox(variable name) is Visible True.

find_real_file.png

Client script:

 

if(g_form.getValue('variable_name')==true){ 

g_form.setVisible('textbox_variable',true); 

}

else{

g_form.setVisible('textbox_variable',false); 

}

 

Hope this helps!

If you have any more questions, please let me know.

If I have answered your question, please mark my response as correct and helpful.

Thanks,

Sriram