Reference field dependency on UI Page

Community Alums
Not applicable

i have a glide window open when i click a UI action. The glide window is actually UI page.

find_real_file.png

<g:ui_reference name="approver_user" id="approver_user" table="sys_user" query="active=true^roles=itil" completer="AJAXTableCompleter" />

Approver is a Reference field and queries user table. Approver Type has 3 drop down values: Responsible Manager, Accountable Director & Individual Approver

I need to modify the query based on the selection value on Approver Type so that i can query Approver field on User table as below,

Ex: query="active=true^roles=itil^u_responsible_manager"   if Approver type is Responsible Manager

Ex: query="active=true^roles=itil^u_accountable_director"   if Approver type is Accountable Director

Thanks in advance!

14 REPLIES 14

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Karthik,



Try to do the following and check


1) Have a onChange script for the drop down field in the ui page.


2) Based on value set the query attribute of g:ui_reference tag



Check whether the values are restricted based on the query



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

Community Alums
Not applicable

Thanks alot for the quick response Ankur !


first time i'm writing UI page jelly scrip, could you please provide the syntax for the HTML/XML & Client Script for this on change.


Hi Karthik,



May be you can refer jelly syntax but basic onChange on input field is here



UI Page HTMl Field


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">




  <g:ui_reference name="user1" table="sys_user" query=""/>


  <input type="text" id="hidden1" value="" onchange="check123(this.value)">text box</input>




  <!-- QUERY:active=true -->





</j:jelly>



Client Script



function check123(value){


  var e = gel("sys_display.user1").value;


  alert(e);


  alert(value);


  document.getElementById("sys_display.user1").setAttribute("name","QUERY:active=true^nameLIKErest");


}



This is just normal code. you will have to work on enhancing the code.



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

Community Alums
Not applicable

Thanks Ankur! i will modify the script as per my requirement and get back to you if any queries or share the code if i make it !!