Dynamically change reference qualifier of reference dropdown field based on another field selection

Kirthika D
Giga Guru

Scope: GRC: Policy and Compliance Management

Table: Policy [sn_compliance_policy]

Field: Type [type]

 

The Type field is an inherited reference dropdown field from the Parent table "Document" [sn_grc_document]. It  references "GRC Choices" [sn_grc_choice] table. This table has multiple sets of choices. Each "Set" corresponds to a table. For one table, it can have several Choice categories. Each "Choice Category" can correspond to a field and can have multiple choices.  

For Example, OOTB, the GRC Choices table has 7 entries where Set = Policy and Choice Category = Type. 

This indicates, the type field will have those 7 entries as choices in a Policy record.

 

This is configured by the dictionary definition of Type field, where the reference qualifier is a javascript call of an OOTB script include. 

 

I have a requirement to limit the choices based on another field on the Policy form. 
For example,

  1. If "Owning group" = Group A, the type field should have choices: Choice 1, Choice 2 and Choice 3 .
  2. If "Owning group" = Group B, the type field should have choices: Choice 1, Choice 5, Choice 6.
  3. If "Owning group" = Group C, then type field should have choices: Choice 6, Choice 7. 

Is there a possibility to achieve this dynamically on change of Owning group?

 

Note: 

  1. I created a list collector field with reference to Groups table on the GRC Choices table called "Allowed Groups".
  2. I selected all groups that should be able to see a particular choice value on Allowed groups field of that Choice record. 
  3. I tried doing a dictionary override to override the existing reference qualifier script. I created my own version of the script include function to include the filter condition which reads "Set = Policy, Choice Category = Type and Allowed Groups Contains Owning Group". I called this function from the dictionary override. This works when the form loads, but does not change the reference qualifier when I change the Owning Group on the form before saving. 
  4.  I tried creating an OnChange client script that sends the group ID to a script include. This script include then gathers all choice records that match the reference qualifier and return the sys_ids and display values. On the client script, in the callback function, I clear the value for the field, then I clear all options and try to add options based on the sys_ids and display values. When executed, the field value does get cleared out, and all existing choices get removed, but the new choices are not getting added. The dropdown does not open to a list. 

Please let me know if there is any correction / workaround I can apply if this is achievable. 

 

Thanks!

1 ACCEPTED SOLUTION

Kirthika D
Giga Guru

Checked other community pages to see that addOption does not work for reference dropdown fields. Decided to use on submit script to prevent saving with choices a group is not supposed to use. 

View solution in original post

5 REPLIES 5

There was no direct resolution I could use to achieve my requirement. I had to use a workaround.

g_form.removeOption works for removing a choice in the pre-filtered dropdown of the reference field.

But g_form.addOption does not work on this type of field. 

 

My goal for the requirement in the first place was to prevent users of certain Owning groups from creating / editing Policy records of certain Types & Categories. 

 

Instead of limiting the choices available, I resorted to display the choices, but prevent saving / submission of records by use of an onSubmit Client script, by evaluating the selection of Types & Categories against the selection of Owning groups.