Restrict choices of a field to be visible on a child.

Kalyani35
Tera Guru

Hi experts,

I have a requirement where we have a field say Type on a cmdb_ci table. This field is meant to have different choices for different classes. FOr example, for class cmdb_ci_server it has 3 choices- 

1. Server 1 

2. Server 2

3. Server 3

Class cmdb_Ci_linux_server should have choices

1. Linux server 1

2. Linux server 2

which works fine, as Linux has defined its own choices on Type field the choices from the parent - cmdb_ci_server will not be available.

But now, for the class cmdb_ci_aix_Server, there are no choices needed as per requirement, but the choices from the cmdb_Ci_linux_server are inherited as Linux is the parent for AIX server.

 

The option of - Configure choices works well on choices inherited from Task to Incidents but when I tried it in above scenario, it does not work.

Is it possible to restrict this inheritance of choices for particular classes in any other way?

@Chuck Tomasi can you please help here? I have seen your replies on may articles with somewhat similar questions, but this is a kind of different behaviour when it comes to using configure choices option.

Thanks in advance!

 

6 REPLIES 6

Sourabh26
Giga Guru

Hi,

 

The workaround is to create an onLoad (and onChange) client script, using the g_form.removeOption() statement to remove the unwanted choices for the parent table.

NOTE: this workaround works for form view, but not for list views. The value will still show up for the dependent field in list view. To deal with that, add a 'list_edit' ACL on the substate field (to prevent updates) or a business rule that validates the value selected by the user when trying to save; aborting the transaction when the selected value is not eligible; Hiding the unwanted value from list view is not possible.

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

Hi Sourabh,

Thanks for reply.

But as there are multiple child classes of CIs I cannot apply the client script for each of the classes. Also, as you mentioned it will not work on the list view.

In that case you should configure the choice separately on each child table instead of adding it on the parent and then hide.

The problem here is we do not want the choices at all on some of the child tables, in which case it inherits the choices from parents.