Choice list

Manu143
Tera Contributor

Hi Community ,

 

  I have urgent requirement on :

1.I need Convert one free text field (e.g abc) to  a drop down with some options.

2.These dropdown/choices should be visible only for particular model category. ( e.g the drop down should be visible only for model category is computer & for rest of the model category it should be free text only)

3.When this(abc) field will populate another filed xyz should get mandatory and when xyz filed will get polulate the abc filed should be mandatory.

How to achieve this?

 

Thanks,

Manu

 

5 REPLIES 5

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Manu143 ,

 

Do u need to do this on catalog item form?

 

If yes you can have 2 different fields instead of 1 (1st field as single line text & 2nd field as drop down) & you can hide Unhide the required field based upon Ui policy / Client Script.

In order to make it mandatory & non mandatory u can write an on Change client script on the both the field (abc & xyz) like 

if(newValue != ''){
g_form.setMandatory('xyz',true);
}else{
g_form.setMandatory('xyz',false);
}

 

Above script needs to be created for both field on change.

 

Thanks,

Danish

 

Hi  Danish Bhairag,

  I want this on alm hardware form.  That free text filed is already there I just need to show some choices for that filed only for model category is computer. I have added choices to field from dictionary but not getting how to make those visible only for computer.

Thanks,

Manu

Hi @Manu143 ,

 

In the choice field dont add any choices by default. You can write an on Change client script on alm hardware table on model category field , something like below.

 

if(newValue == 'Computer'){ // Use proper backend name of the computer value
g_form.addOptions('model_category','Option1');
g_form.addOptions('model_category','Option2');
g_form.addOptions('model_category','Option3');
}else{
g_form.removeOptions('model_category');
}

 

 

Thanks,

Danish

  

Hi 

Hi Danish Bhairag2,
  It's not working. For onload I tried but we have to add the choice with dropdown None and if I will add this it will also reflect for model category other than computer.
 
 
Thanks,
Manu
PREVIEW