- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 06:57 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 01:42 PM
I have found a solution: I converted the array to a string, and with the numbers of the changes, I also passed the following text to the ui page:
^NQnumberSTARTSWITH
This is how I passed it to the UI page:
<j:set var="jvar_numbers" value="${RP.getWindowProperties().get('Change_Requests')}">
</j:set>
<g:ui_reference name="number" id="number" query="${jvar_numbers}" table="change_request" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 07:51 AM
I noticed a few adjustments and clarifications that can be made to ensure correctness and effectiveness:
Updated UI Page HTML 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:ui_form>
<table>
<tr>
<td style="width:25%">
<g:form_label>Select Change Request:</g:form_label>
</td>
<td style="width:60%">
<g:ui_reference name="number" id="number" query="active=true^sys_idIN${gs.getList('sysparm_number')}" table="change_request" />
</td>
</tr>
<tr>
<td colspan="2">
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="continueOK()" ok_type="button" ok_text="${gs.getMessage('Submit')}" ok_style_class="btn btn-primary" cancel_type="button" cancel_id="cancelData" cancel_style_class="btn btn-default" cancel="continueCancel()"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Explanation and Adjustments:
1. UI Reference (`<g:ui_reference>`):
- Changed `query="active=true^sys_idIN${request.getParameter('sysparm_number')}"` to `query="active=true^sys_idIN${gs.getList('sysparm_number')}"`.
- Uses `gs.getList('sysparm_number')` to retrieve the comma-separated list of `sys_id` values passed from the UI Action. `gs.getList()` is preferable in this context to handle arrays passed from UI Actions correctly.
2. Dialog Buttons:
- Consolidated the OK and Cancel buttons under `<td colspan="2">` for clarity and proper alignment.
Additional Tips:
- Parameter Passing: Ensure that `sysparm_number` is correctly passed as a comma-separated list of `sys_id` values from your UI Action (`dialog.setPreference('sysparm_number', lista)`).
- Testing: Test the UI Action and UI Page integration to verify that only the specified change requests are displayed based on the passed `sysparm_number`.
By implementing these adjustments, the UI Page should correctly display and filter change requests based on the array passed from the UI Action, ensuring the functionality aligns with your requirements.
———————————————————-
If my response helps, please mark it as "Accept as Solution" and consider it "helpful."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 09:57 PM
Thank you for your help!
Unfortunately the list is now empty. 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 10:27 PM
Verify Parameter Passing: Confirm that sysparm_number is correctly set in your UI Action using dialog.setPreference('sysparm_number', lista).
Check UI Page Query: Ensure you're using gs.getList('sysparm_number') in your UI Page's <g:ui_reference> query attribute to fetch and filter based on sys_id values.
Debugging Steps: Log sysparm_number in the UI Page to ensure it's correctly received and contains the expected values. Check for any errors in the browser console or server logs.
Direct Query Testing: Validate the generated query (active=true^sys_idIN${gs.getList('sysparm_number')}) directly in your ServiceNow instance to confirm it returns results.
--------------------------------------------------------------------------------------------------------------------
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 12:29 AM
As you can see, the sysparm_number is correctly set in the UI Action.
the first alert says:
the second alert says:
Here is the UI Page HTML: