How can I add an advanced reference qualifier in a UI Page Jelly script?

Suvitha Murugan
Tera Contributor

Hi,

I tried adding an advanced reference qualifier on a UI Page, but it’s not working as expected. I want to display the values dynamically based on the current record. Could someone help me resolve this issue?
Thanks in advance
Script:

<?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_sys_id" expression="RP.getParameterValue('sysparm_sys_id');" />
    <input type="hidden" id="record_sys_id" value="${jvar_sys_id}" />
    <style>
        label {
            font-weight: bold;
            margin-bottom: 5px;
            display: block;
        }
    </style>

    <g:ui_form>
        <table border="0" width="100%">
            <tr>
                <td style="width:10%">
                    <label for="Business XXX">Business  XXX</label>
                </td>
                <td style="width:25%">
                    <g:ui_reference name="user" id="user" table="xxxxxx" query="new x_Utils().getXXXXUsers('${jvar_sys_id}')" />

                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:right;padding-top:10px;"> <button class="btn btn-default" onclick="closeWindow()" style="margin-right:10px;">Cancel</button> <button class="btn btn-primary" onclick="update_button()">Submit</button> </td>
            </tr>
        </table>
    </g:ui_form>
</j:jelly>
1 ACCEPTED SOLUTION

nishant3101
Giga Contributor

Hi Suvitha,

 

This usually happens because the <g:ui_reference> tag expects a pure encoded query string, but the Script Include call inside the query attribute is not being executed the way we think. The Jelly engine treats it as a literal string, so the filter never applies.

To make the dynamic qualifier work on a UI Page, we need to evaluate the Script Include server-side first and then pass the returned encoded query to the reference field.

Here’s the working approach:

 

<g:evaluate var="jvar_sys_id" expression="RP.getParameterValue('sysparm_sys_id');" />
<!-- Execute the Script Include on the server and store the encoded query -->
<g:evaluate var="qual" expression="(new x_Utils()).getXXXXUsers(jvar_sys_id)" />

<input type="hidden" id="record_sys_id" value="${jvar_sys_id}" />

<g:ui_form>
<table border="0" width="100%">
<tr>
<td style="width:10%">
<label for="Business XXX">Business XXX</label>
</td>
<td style="width:25%">
<!-- Use the evaluated qualifier here -->
<g:ui_reference name="user" id="user" table="xxxxxx" query="${qual}" />
</td>
</tr>
</table>
</g:ui_form>

 

A couple of notes that helped me debug this:

  • Ensure your Script Include getXXXXUsers() returns a valid encoded query, something like:
    active=true^business_unit=<some_sys_id>

  • You can temporarily print these values for testing:
    <pre>sys_id = ${jvar_sys_id}</pre>
    <pre>qual = ${qual}</pre>

Once I switched to this pattern, the reference qualifier started filtering correctly based on the current record.

 

If this helps you, please mark the answer as Resolved so it can help others too. 😊

View solution in original post

1 REPLY 1

nishant3101
Giga Contributor

Hi Suvitha,

 

This usually happens because the <g:ui_reference> tag expects a pure encoded query string, but the Script Include call inside the query attribute is not being executed the way we think. The Jelly engine treats it as a literal string, so the filter never applies.

To make the dynamic qualifier work on a UI Page, we need to evaluate the Script Include server-side first and then pass the returned encoded query to the reference field.

Here’s the working approach:

 

<g:evaluate var="jvar_sys_id" expression="RP.getParameterValue('sysparm_sys_id');" />
<!-- Execute the Script Include on the server and store the encoded query -->
<g:evaluate var="qual" expression="(new x_Utils()).getXXXXUsers(jvar_sys_id)" />

<input type="hidden" id="record_sys_id" value="${jvar_sys_id}" />

<g:ui_form>
<table border="0" width="100%">
<tr>
<td style="width:10%">
<label for="Business XXX">Business XXX</label>
</td>
<td style="width:25%">
<!-- Use the evaluated qualifier here -->
<g:ui_reference name="user" id="user" table="xxxxxx" query="${qual}" />
</td>
</tr>
</table>
</g:ui_form>

 

A couple of notes that helped me debug this:

  • Ensure your Script Include getXXXXUsers() returns a valid encoded query, something like:
    active=true^business_unit=<some_sys_id>

  • You can temporarily print these values for testing:
    <pre>sys_id = ${jvar_sys_id}</pre>
    <pre>qual = ${qual}</pre>

Once I switched to this pattern, the reference qualifier started filtering correctly based on the current record.

 

If this helps you, please mark the answer as Resolved so it can help others too. 😊