how to pass value from g:ui_reference to another g:ui_reference as part of query?

Ratish1
Tera Contributor

Hi,

I want user to choose a user in Ui page page in the reference field and want that value to be a part of another reference field query

<g:ui_reference name="user" id="user" table="sys_user" />

<g:ui_reference name="incident" id="incident" table="incident"   query="caller_id=${value of first reference field}"/>

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ratish,



I assume you want following this:


Based on first ui_reference selection apply query on second ui_reference and restrict records.



I have provided solution to this in following links.


How to make assigned_to field dependent on assignment group on a UI page


Change ui reference query


Reference field dependency on UI Page



Refer the same and you should be able to achieve that.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ratish,



I assume you want following this:


Based on first ui_reference selection apply query on second ui_reference and restrict records.



I have provided solution to this in following links.


How to make assigned_to field dependent on assignment group on a UI page


Change ui reference query


Reference field dependency on UI Page



Refer the same and you should be able to achieve that.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

venkatiyer1
Giga Guru

Hi Ratish,



you can use a client script to populate the second field with the sys_id of the first field. You can use the id field that you defined to get the value and populate it accordingly.


Ratish1
Tera Contributor

Thanks Ankur,



var UserLookUp = gel('lookup.locationRecords');


UserLookUp.setAttribute('onclick',"mousePositionSave(event); reflistOpen( 'locationRecords', 'not', 'cmn_location', '', 'false','QUERY:active=true',           'sys_idIN" + locationArray+ "', '')");



with some changes did the trick for me. Thanks again


Hi Ratish,



Great that it worked. It would be nice if you endorse the content. Thanks in advance.



How to Endorse Content



Regards


Ankur


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