Advanced Reference Qualifier for reference field

Mari2
Kilo Guru

Hello,

 

I have difficulty to setup advanced qualifier, and hope someone can give me some idea.

 

I have two fields called ‘Owner department’ and ‘Catgory (DX)’ on incident form. Both fields are reference field, and are referencing another table (u_corporate_dx). Depends on the value selected on ‘Owner department’, I’d like to display different options for ‘Category (DX)’.

 

Owner department field is displaying records, which have ‘Owner department’ tag.

Mari2_0-1687738760467.png

 

 

For Catgory (DX) field, I’d like to display the records, which the display value selected on ‘Owner department’ equals to ‘Dependent parent’ value. For example, when NYCAK is selected on ‘Owner department’, I would like to display

 â€˜Accutal WF’, ‘BizPlan NYCAK Input Forms’, and ‘NYCAK Accounting Workflows’ for ‘Categry (DX) field. The below is Corporate DX table’s records.

Mari2_1-1687738760482.png

I was originally thinking of using combination of simple Reference Qualifier and onChange client script (field name =   owner department) below. but realized addOption does not work for reference field. And I found several community articles suggesting using Advanced Reference Qualifier. But I do not know how I can achieve this requirement using Advanced Reference Qualifier. Can someone give me some insights? Thank you.

 

Mari2_2-1687738760494.png

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

   if (isLoading || newValue === '') {

      return;

   }

              var newValue_text = "";

    var gr_value_name = new GlideRecord('u_corporate_dx');

    gr_value_name.addQuery('sys_id', newValue);

    gr_value_name.query();

    while(gr_value_name.next());

    {

        alert(gr_value_name.sys_id);

                             alert(newValue);

                             newValue_text = gr_value_name.u_value;

                            

      //  break;

    }

 

    g_form.clearOptions('u_category_dx');

   

    var gr = new GlideRecord('u_corporate_dx');

    gr.addQuery('u_dependent_parent', newValue_text);

    gr.query();

    while(gr.next());

    {

        g_form.addOption('u_category_dx', gr.u_value, gr.u_value);

    }

}

 

1 ACCEPTED SOLUTION

Hi, I have been unable to get my PDI to shows reference fields as choice lists, even after following the SNC documentation, so cannot reproduce your issue. But I suspect this reformatting of the reference field to chocie is the reason why you are not seeing the ref qualifier function as it should. I would think the easiest option would be to use reference fields as reference fields, otherwise you might have to write client script to hide specific 'choice' values using removeOption
GlideForm | ServiceNow Developers

View solution in original post

12 REPLIES 12

Hi, from a record form (IE incident) a dictionary reference qualifier works on value change, and as indicated your scenario works without issue in a PDI - can you confirm you are using a record 'form' and not a catalog item\record producer?


I would start by getting the base ref qualifier to work, and then look at adding your 'tags' query to it, as the code you have posted looks incorrect and would result in error\unexpected results which would complicate the situation.

javascript: 'u_dependent_parent=' + current.u_owner_department.sys_id + '^sys_tags=f6c24cf787176110814c217f8bbb356a'; 

 

Mari2
Kilo Guru

Hi Tony,

 

>can you confirm you are using a record 'form' and not a catalog item\record producer?

Yes, this is an incident form. 

 

>I would start by getting the base ref qualifier to work, and then look at adding your 'tags' query to it

I removed the 'tag' query as below, but the it is still not working on field change. 

javascript: 'u_dependent_parent=' + current.u_owner_department.getDisplayValue();

 

Mari2_0-1687828630638.png

 

For example, when owner department is set as --None--, Options for Category (DX) are below. 

Mari2_1-1687828852401.png

 

When I select 'NYCAA' for Owner department, the options for Category (DX) does not change.

Mari2_2-1687829052825.png

Once I save this incident form, the options for  Category (DX) changes.

Mari2_3-1687829120969.png

Hi, you stated in your first post that Owner department and Category (DX) were both reference fields for the same table (u_corporate_dx), yet the screenshot in your last post appears to show both Owner department and Category (DX) as choice lists with --None-- option enabled.

Can you clarify your configuration?

 

Hello Tony, 

 

Yes, both Owner department and Category (DX) are reference field. Please see the screenshot below. 

Mari2_0-1687832001125.png

 

Mari2_1-1687832038744.png

I selected 'Drop down with --None--' under 'Choice List Specification' tab. 

Mari2_2-1687832109337.png

 

 

Hi, I have been unable to get my PDI to shows reference fields as choice lists, even after following the SNC documentation, so cannot reproduce your issue. But I suspect this reformatting of the reference field to chocie is the reason why you are not seeing the ref qualifier function as it should. I would think the easiest option would be to use reference fields as reference fields, otherwise you might have to write client script to hide specific 'choice' values using removeOption
GlideForm | ServiceNow Developers