Variables visibility condition

sanjana5
Tera Contributor

there is check box and  a reference field on catalog item which referes to ABC Table. if fields on table is empty and check is False then catalog item variables should visible
if check box == false and referencefield.table fields == empty
then XYZ variable should visible and mandatory
@BharathChintala 

Thanks in Advance

1 ACCEPTED SOLUTION

BharathChintala
Mega Sage

@sanjana5 in catalog ui policies dot.walking is not possible.

 

You have to write client script

 

it should be onChange catalog client script

Since I can't see your form. I am sending script in regular way modify based on your requirement.

BharathChintala_0-1676641051763.png

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {// if onload or when that field is empty if you want hide something write below
   //g_form.setValue('variable1',false);// you can add more variables based on requirement
      return;
   }
   var user = g_form.getReference('user',getuserfields);// in my example user is reference field
}
function getuserfields(user){
var check = g_form.getValue('variable');// give checkbox variable name
if(check==false && user.employee_type == ''){//like this you can check reference fields and check box combimnation
    g_form.setDisplay('variable2',true);
    g_form.setMandatory('variable2',true);//replace your varibales which need to show and mandate
}else{
    g_form.setDisplay('variable2',false);
    g_form.setMandatory('variable2',false);//this is important give in else to work on opposite 
}
}
If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

View solution in original post

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can create a Catalog ui policy as below and then add ui  policy actions to show / hide / make mandatory . On the ui policy you can add the condition as you mentioned.

I am not sure i understand the challenge fully.

 

-Anurag

Community Alums
Not applicable

Reference field is Department which references the cmn_department table.

I have created a demo checkbox field named CheckboxVariable.

XYZ field as single line text variable.

So as per the above mentioned requirement,the XYZ variable is only visible when the Department is empty and the checkbox is false.

Please write Catalog UI policy to make XYZ variable visible and mandatory as follows.

CatalogUIPolicy.pngUI action.png

 

Please mark it as Helpful if it works.

Thank you!

BharathChintala
Mega Sage

@sanjana5 in catalog ui policies dot.walking is not possible.

 

You have to write client script

 

it should be onChange catalog client script

Since I can't see your form. I am sending script in regular way modify based on your requirement.

BharathChintala_0-1676641051763.png

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {// if onload or when that field is empty if you want hide something write below
   //g_form.setValue('variable1',false);// you can add more variables based on requirement
      return;
   }
   var user = g_form.getReference('user',getuserfields);// in my example user is reference field
}
function getuserfields(user){
var check = g_form.getValue('variable');// give checkbox variable name
if(check==false && user.employee_type == ''){//like this you can check reference fields and check box combimnation
    g_form.setDisplay('variable2',true);
    g_form.setMandatory('variable2',true);//replace your varibales which need to show and mandate
}else{
    g_form.setDisplay('variable2',false);
    g_form.setMandatory('variable2',false);//this is important give in else to work on opposite 
}
}
If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala