Please help with Client Script to hide a text box.

Lisa Goldman
Kilo Sage

Hello,

I have the following 2 variables on a Catalog Item.

  1. Single Row Variable Set
  2. Single Line Text Variable

LisaGoldman_0-1691523288638.png

 

I need help on Client Script if Single Row Variable is empty, hide the Employee ID Text Box else don't hide it.

 

Thank you

 

12 REPLIES 12

Hello @Prince Arora 

Could you please try the following steps in your PDI to see if it works?  I could not get it works.  

1.   Create a Single Row Variable Set

LisaGoldman_0-1691546619408.png

2.  Create "Request for" type variable in side of Single Row Variable Set

3.  Under "Type Specifications" Tab, Select "Enable also request for" check box

LisaGoldman_1-1691546721946.png

4.  Create a Single Line Text Variable

 

LisaGoldman_3-1691547040883.png

 

5.    Use UI policy and see if you can hide the "Also request for"  field.

LisaGoldman_2-1691546930807.png

 

Thank you

 

smkreddy
Tera Contributor

use client script 
via requestedfor = g_form.getValue("requested_for")

if(requestedfor == ' '|| requestedfor == ){
g_form.setVisible('emp iD back end value' false);

}

@smkreddy,

Suggestion script is not working.  "requested_for" is not the internal name for "Also request for"

go to the catalog item and go down and variable will present. open the   " Also request for" variable open copy the back end value and replace with requested for name to Also request for

Example back end value: 

smkreddy_0-1691721438576.png

 on change client script: on variable  "Also request for"

if (isLoading || newValue == '') {
     return;
    }

 

if (newValue == ){
g_form.setVisible('emp iD back end value' false);

}

 

what is your reasoning for scripting this? this can easily be done in a UI Policy as multiple people on this thread have stated.