UI Page GlideAjax not triggering when passing value from UI Macro/GlideModal using setPreference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Hi Everyone,
I am working on a requirement where I created a custom button using a UI Macro and displayed it on the form using a Formatter.
When user clicks the button:
- A GlideModal opens
- A UI Page loads
- I pass a CyberGRX ID from UI Macro to UI Page using:
gm.setPreference("sysparm_grx_id", grx_id);
Inside the UI Page, I am able to retrieve and display the value successfully using:
<g>
var grxId = RP.getParameterValue('sysparm_grx_id');
</g>
and:
${grxId}
The issue:
I am trying to use this grxId inside client-side JavaScript in the UI Page and trigger a GlideAjax call, but the API/GlideAjax is not executing.
UI PAGE HTML code is: -
<?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 grxId = RP.getParameterValue('sysparm_grx_id');
</g:evaluate>
<h2>CyberGRX ID:</h2> ${grxId}
<script>
var grxId = "${grxId}";
showData();
</script>
<div>
<!-- <p>"This is just a demo for review."</p> -->
<table border="1" style="width:100%; border-collapse:collapse; text-align:left;">
<thead>
<tr>
<th>Risk Domain</th>
<th>Domain Index</th>
<th>Domain Index Rating</th>
<th>Domain Impact</th>
<th>Domain Descriptiong</th>
</tr>
</thead>
<tbody id="tableBody"></tbody>
</table>
</div>
</j:jelly>
and Client script code is like -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Ajays0396044436 ,
Make sure that your client callable script where Ajax resides is set to this scope application only not all applications.
please mark helpful if this solves your problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
is your script include client callable?
is the ajax call working?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
34m ago
1. In the Client Script section of your UI Page, use GlideModal's get().getPreference()to access the ID you passed from the UI Macro.
2. Instead if RP.getParameterValue , try with RP.getWindowProperties()
Refer code from this post:
https://www.servicenow.com/community/developer-forum/custom-glidemodal/m-p/2837020