How can we define Dynamic Reference Qualifier in HTML Body - UI Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 01:07 PM
In UI Page scripting, Can we take the values from "Client Script" and define that as a Dynamic Reference Qualifier in the "HTML" body?
As per my requirement: I have to show Stockrooms based on the "requested_for" country
So this client script is successfully fetching the Country details of the "requested_for" user.
So, we are storing the Country of the requested for in 'answer'.
But, when coming to HTML
In query, I know how to add the static filter, but in the place of sys_id, I should pass the whatever value that comes in 'answer' in the given client script. So that it will become a dynamic filter condition.
Based upon the requested_for --> Country, we need to display the stockrooms

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 01:57 PM
Hi @Irfan Khan Path ,
The issues i can see is- <g:ui_reference> tag is hardcoded and doesnt update based on the client script’s answer value.
One more issue - The reference qualifier is defined in the HTML body before the client script fetches the value
Please find the updated scripts-
Client Script-
(function () {
var selectedUser = g_form.getValue('requested_for');
var ajaxexample = new GlideAjax('CountryUtils');
ajaxexample.addParam('sysparm_name', 'getCountry');
ajaxexample.addParam('sysparm_user', selectedUser);
ajaxexample.getXMLAnswer(function(response) {
var answer = response;
g_form.addInfoMessage("Country: " + answer);
// update the reference qualifier dynamically
updateStockroomReferenceQualifier(answer);
});
})();
function updateStockroomReferenceQualifier(country) {
var stockroomField = g_form.getControl('stockroom');
stockroomField.setAttribute('data-ref-qual', 'location.u_location_country=' + country);
g_form.clearOptions('stockroom');
g_form.addOption('stockroom', '', '-- None --');
}
HTML-
<tr>
<td style="text-align:right;">
<label style="color:red">*</label>
<label id="stockroom_label" title="${gs.getMessage('Stockroom to which the loaner asset is returned')}">
${gs.getMessage('Stockroom:')}
</label>
</td>
<td id="td_reference_stockroom">
<g:ui_reference name="stockroom" id="stockroomId" table="alm_stockroom" aria-labelledby="stockroom_label"/>
</td>
</tr>
If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 02:35 AM
Hello Sanjay,
Thanks for your reply.
But its not working. I have to use the Dynamic filter in HTML by taking the Country Value from Client Script. Is that Possible.
As per your code, I'm getting the sys_id of that 'requested_for".
With that country, we have to add it in the place of below sys_id, so that it will apply the filter dynamically, Is that possible?
query= "location.u_location_country=2450e7eddbff764005ea766eaf9619ec/>
Thanks...