Choice field with dependent field refering to the reference table field not working

snehapatel
Tera Contributor

Hi,

 

I have defined a custom table which includes following 2 fields among others:

 

Field 1 -> reference to sys_user_group

Field 2 -> Choice field with dependent field as Field 1.name (i.e. referring to sys_user_group.name)

 

The requirement is whenever on Field 1, Group 1 is chosen, the choice field should display certain set of values and when Group 2 is chosen another set of values should be displayed. My choice values are defined against the sys_user_group.name values which is the dependent field.

 

In the form, whenever I chose a value for Field 1, the choice field field does not show any values. It looks like the matching of the choice values happens against the sysid of sys_user_group and not against the <name> of sys_user_group. 

 

How to make this work. Please help

1 ACCEPTED SOLUTION

Hi @snehapatel 

 

1) 

  • Create a new field (let’s call it group_name), type String, on your custom table.
  • Mark it as calculated.
  • In the dictionary record, add the calculation, something like:

// Assuming 'u_group' is your reference field to sys_user_group
if (u_group)
answer = u_group.name;
else
answer = '';

 

  • Now, in your choice field dictionary entry, set the Dependent field = group_name.
  • Define your choice dependencies against group_name values (the human-friendly group names).

2)

  • You’d need to ensure groups are moved via update sets so they keep the same sys_id in all environments.
  • This is fragile and not recommended — especially since sys_user_group often contains environment-specific groups.
  • That’s why using names (via calculated field) or a custom mapping table is a safer and more portable approach.

 

View solution in original post

13 REPLIES 13

@Ankur Bawiskar 

 

I am not trying to showing the group name in 2nd field. The 2nd field is a choice field and the choice values are dependent on group name. For example if on 1st field group A is selected, 2nd field should show values 1,2,3. If group B is selected, then it should should show 4,5,6 and so on. Currently this is no happening as the matching happens against the sys_id and not group.name field even if the dependent field value is group.name.

 

Thanks,

Sneha

@snehapatel 

so you can write onChange client script and then add/remove options using g_form.addOption() and g_form.removeOption()

If my response helped please mark it correct and close the thread so that it benefits future readers.

@snehapatel 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

@Ankur Bawiskar ,

Thanks for your response

Using add or remove option will defy the purpose of configuring the choices and dependent field. So I would not go for it.

 

Thanks,

Sneha