How to dynamically set reference qualifier to the reference field on ui page in serviceNow

Pooja Mahamuni
Tera Contributor

Hi,

 

I have created an ui page which has 2 reference fields :

1. Project:

2. Epic related to above project:

Attaching screenshot for reference:

I want to show the epics related to project selected in 1st reference field in a 2nd reference field. I can get sys_id of above selected project but not able to pass this dynamically to "query" parameter of second reference field.

 

Here is my code:

 <! -- 1st reference field: -->

 <div nowrap="true" type="string" choice="0" data-type="label">
                        <label class="col-sm-12 col-md-3 control-label" for="sys_display.document_key">
                            <span class="label-text">Project/Demand</span>
                        </label>
      </div>
  <div class="form-field col-sm-12 col-md-6 input_controls">
          <g:ui_reference name="document_key" id="document_key" table="${table_name}" query="sys_class_name=pm_project^ORsys_class_name=dmn_demand^active=true" onchange="showEpicReference()" />
 </div>
<! -- 2nd reference field: -->
<div id="epicRef">

                <div nowrap="true" type="string" choice="0" data-type="label">
                    <label class="col-sm-12 col-md-3 control-label" for="sys_display.document_key1">
                        <span class="label-text">Epic ${jvar_filer}</span>
                    </label>
                </div>
                <div class="form-field col-sm-12 col-md-6 input_controls">
                    <g:ui_reference name="document_key1" id="document_key1" table="rm_epic" query="" />
                </div>
            </div>

 

In second reference field we need to pass query based on selected project but not able to understand how.

 Is there any way to achieve it?

 

Thanks

Pooja

3 REPLIES 3

Sanjay191
Tera Sage

Hello @Pooja Mahamuni 

Please check the below thread it might be helpful for you 

https://www.servicenow.com/community/developer-forum/change-ui-reference-query/m-p/1729102

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You


Ankur Bawiskar
Tera Patron
Tera Patron

@Pooja Mahamuni 

I shared solution for this 7-8 years ago and it still works, check below link and see my response

Change ui reference query 

AnkurBawiskar_0-1749214789266.png

 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Pooja Mahamuni 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader