How to Add Selected options one field as selection for another field?

Pratiksha_kadam
Tera Contributor

Hello,

we have the requirement to create one field that contains choices from another field. 

Example: -

Suppose there are two field 'A' and field 'B'. Field A is multiselect field where we can select multiple options. Whatever selected in field A those will be the choice for B. For B we have to select any one of option from those options of 'A'. When multiselect field 'A' contain only one selection then field 'B' contain that as default value. we have to make ' B ' field mandatory when 'A' field contains more than one selection.

please guide me to implement this functionality.

Thanks in advance.

1 ACCEPTED SOLUTION

Hi,

You need use advanced Reference qualifier on Field B like below:

 javascript: "sys_idIN"+current.u_field_a

 

It will restrict list to options selected in 1st Field.

To achieve 2nd scenario, you need to create onChange Client script running on change of 1st field.

 

Use logic in your client script like below:

 

var first = g_form.getValue('u_field_a');
var arr = first.split(",");
if(arr.length<1){
g_form.setValue("u_field_b",newValue);
}
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

10 REPLIES 10

Anil Lande
Kilo Patron

Hi,

Can you please share your field configuration (Is it variable on Catalog form or List field on Table?)

If List field then is it referring to any table or you have added choices?

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi,

Field 'A' is referencing to the business capability table of list type and field 'B' is also on table which should display the dropdown values selected in field 'A'.

I hope it helps to solve the query.

Thanks

Hi,

You need use advanced Reference qualifier on Field B like below:

 javascript&colon; "sys_idIN"+current.u_field_a

 

It will restrict list to options selected in 1st Field.

To achieve 2nd scenario, you need to create onChange Client script running on change of 1st field.

 

Use logic in your client script like below:

 

var first = g_form.getValue('u_field_a');
var arr = first.split(",");
if(arr.length<1){
g_form.setValue("u_field_b",newValue);
}
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thanks!

It is working. I am trying to make field 'B' mandatory through the same client script when selections in field 'A' is more than 1. However, it is not working.