Reference field within UI Page not working

matthew_hughes
Kilo Sage

I'm working on the following UI Page on a Business Application form:

matthew_hughes_0-1744205777485.png

 

When the user clicks on the reference field, I'm expecting any children of the Business Application. So where an Application Service has the current Business Application selected as 'Business Application Name', which is also a reference field.

 

matthew_hughes_2-1744205997481.png

 

 

I'm trying to use the following code to achieve this in the HTML part of my UI Page:

<div id="referenceField" style="display:none; margin-top: 10px;">
                <g:ui_reference name = "application_services" id="application_services" table="cmdb_ci_service_discovered" query="u_bus_app_name=this.app_id"/>
            </div>
 
However, when I click on the reference field, I don't get any results:
matthew_hughes_1-1744205944065.png

 

Does anyone know where I'm going wrong?

 

1 ACCEPTED SOLUTION

@matthew_hughes 

So based on current business app the filter should be applied

See this how I was able to show only incident assignment group in reference field

I passed the group sysId and collected that in UI page and then used query attribute to set the filter

You can also enhance for something similar for your case

UI Action:

 

var gm = new GlideModal('myTestingHtmlInput');
	gm.setTitle('My Page');
	gm.setPreference('sysparm_group', g_form.getValue('assignment_group'));
	gm.setSize('600', '600');
	gm.render();

 

UI Page:

<?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:evaluate var="jvar_group" expression="RP.getWindowProperties().get('sysparm_group')" />

		<g:ui_reference id="group" name="group" table="sys_user_group" query="sys_idIN${jvar_group}" completer="AJAXTableCompleter"/>


</j:jelly>

Output:

AnkurBawiskar_0-1744214973534.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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@matthew_hughes 

so the reference field should show filtered results?

if yes then based on what?

From where are you calling this UI page?

what's your actual business requirement?

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

Yes. That is correct. 

 

It's based on the business application that the user has currently got open.

 

It's coming from a UI Action.

@matthew_hughes 

So based on current business app the filter should be applied

See this how I was able to show only incident assignment group in reference field

I passed the group sysId and collected that in UI page and then used query attribute to set the filter

You can also enhance for something similar for your case

UI Action:

 

var gm = new GlideModal('myTestingHtmlInput');
	gm.setTitle('My Page');
	gm.setPreference('sysparm_group', g_form.getValue('assignment_group'));
	gm.setSize('600', '600');
	gm.render();

 

UI Page:

<?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:evaluate var="jvar_group" expression="RP.getWindowProperties().get('sysparm_group')" />

		<g:ui_reference id="group" name="group" table="sys_user_group" query="sys_idIN${jvar_group}" completer="AJAXTableCompleter"/>


</j:jelly>

Output:

AnkurBawiskar_0-1744214973534.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

@matthew_hughes 

Hope you are doing good.

Did my reply answer your question?

I believe I have answered your question and you can enhance it further.

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