Not able to use the query in Ui page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 02:13 AM
hi everyone i am trying to fetch the records from a table in ui page but not able to use the query its working fine but when i use the addQuery its not working.
This is the HTML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 03:24 AM
@gautam_dhamija wrote:hi everyone i am trying to fetch the records from a table in ui page but not able to use the query its working fine but when i use the addQuery its not working.
This is the HTML
<?xml version="1.0" encoding="utf-8" ?><j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"></script> --><input type="" id="hidden_vendor_code" name="vendor_code" value=""/><g:evaluate object='true' var="jvar_gr" jelly="true">var incGR = new GlideRecord('x_perii_account_0_advanced_type');incGR.orderByDesc('sys_updated_on');incGR.addQuery('vendor_code','vendor_code');incGR.setLimit(5);incGR.query();</g:evaluate><h3>View All Advances by Vendor</h3><table id="incTable" class="table table-striped table-bordered hide-query-stats"><tr><!--<th>Invoice Number ${jvar_sysid}</th> --><th>PO Number</th><th>Advance Type</th><th>Advance Amount Paid</th><th>Advance Payment Date</th></tr><j:while test="${incGR.next()}"><tr><!--<td>${incGR.invoice_number}</td> --><td>${incGR.po_number}</td><td>${incGR.advanced_type}</td><td>${incGR.advance_amount_paid}</td><td>${incGR.payment_date}</td></tr></j:while></table></j:jelly>This is the client script.:var urlParams = new URLSearchParams(window.location.search);var vendor_code = urlParams.get('vendor_code');gel('hidden_vendor_code').value = vendor_code;So i want to show the record on the basis of the vendor code field but not able to glide through it.It is showing all the data from the table
Hello,
I also have some suggestion.
Pass the Vendor Code Properly: Ensure that the vendor_code value is correctly passed from the client-side script to the Jelly script. This involves getting the vendor_code from the URL and setting it in the hidden input field (hidden_vendor_code).
Modify the GlideRecord Query: In your Jelly script, you need to make sure that the vendor_code value from the input field is used in the query. Currently, you are passing the string 'vendor_code' in the query, but you should be passing the actual value of the vendor_code parameter that was set on the client-side.
Ensure the Query Filters Correctly: When you perform the query with addQuery, make sure it uses the dynamic value (vendor_code) from the input field. This ensures that only records matching the actual vendor code will be displayed, not all records.
To summarize:
Set the vendor_code from the URL to the hidden field using client-side JavaScript.
Ensure the Jelly script retrieves this value and passes it into the GlideRecord query.
The query should use the actual value of vendor_code to filter the records, instead of using a literal string like 'vendor_code'.
Best Regards
denial768
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 08:46 PM
I am not able to retrieve the value from client script in the JavaScript can you please tell how we can do that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 09:40 PM
how are you calling this UI page? Is it from an UI action using GlideDialogWindow?
Please share that detail as well.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 09:41 PM
Yes calling it from a ui action