UI Page get value from g:ui_reference and pass to script include

reginabautista
Kilo Sage

Hi guys,

I have two reference fields on a UI Page. I would like the second reference field to display values depending on what's selected on the first reference field and pass this value to a script include. Would you know how to achieve this? My code javascript:busServiceBulkUpdateQuery($('channel').value)does not work.. goranlundqvist any ideas?

<div class="form-group">

  <label class="reference-label">${gs.getMessage('Channel')}</label>

  <g:ui_reference class="col-xs-12" name="channel" table="u_cmdb_ci_service_channel" query="u_active=true" />

  </div>

  <div class="form-group">

  <label class="reference-label">${gs.getMessage('Business Service')}</label>

  <g:ui_reference name="bus_svc" table="u_cmdb_ci_service_business" query="javascript:busServiceBulkUpdateQuery($('channel').value)" />

  </div>

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Regina,



I have posted something similar on below links i.e. second ui reference should be dependent on first ui reference. Not sure on the script include part you are asking.


I achieved it without using script include.



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


Change ui reference query


Reference field dependency on UI Page



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

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Regina,



I have posted something similar on below links i.e. second ui reference should be dependent on first ui reference. Not sure on the script include part you are asking.


I achieved it without using script include.



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


Change ui reference query


Reference field dependency on UI Page



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

Hi Ankur



I couldn't make it work on my use case Mine requirement is quite simple..Just pass the value of the Business Service (g:ui_reference) on the query below. I've now removed the Script Include as it appears that it is a quite straightforward query.   Would you know how I could accomplish this?



Get value from this:


<div class="form-group">


  <label class="reference-label">${gs.getMessage('Business Service')}</label>


  <g:ui_reference name="bus_svc" table="u_cmdb_ci_service_business" query="u_active=true" />


  </div>



and pass to this:


  <div class="form-group">


  <label class="reference-label">${gs.getMessage('Classification')}</label>


  <g:ui_reference name="classification" id="classification" table="sys_choice" query="name=incident^dependent_value=pass value here" />


  </div>


Hi Regina,



As per my earlier responses in those questions you need to have a client script section to handle this i.e. setting the filter attribute dynamically.



Did you try using the client script section as well to set the filter attribute as per my comments on those questions. Using that you should be able to achieve that.



It's simple. onChange of first lookup I am calling method present in client script section and setting the filter attribute for second <g:ui_reference> tag.



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

These posts are not available any more, is there anyway you can help me figure out how to get a reference field to be dependant on another reference field, they are both pointing to sys_choice table.