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

Tony,

I changed 'Choice List Specification' choice to '--None--', and confirmed it's working. Thank you so much for your help!

 

Mari2_0-1687884776497.png

 

Community Alums
Not applicable

Hi @Mari2 ,

 

Your Reference qual above is ok:

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

You just need to add in 'Dependent Field' tab with 'u_owner_department' then it will works.

Kilo, thanks for your advice!