๐ Passing Values from UI Action to Jelly UI Page in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ06-30-2025 09:29 PM
Hey ServiceNow folks! ๐
Ever needed to pass data from a UI Action to a UI Page and then use that value in Jelly?
Well, hereโs a clean and tested example that demonstrates how to:
โ
Grab a value (like assignment_group from the form)
โ
Pass it to a UI Page using GlideDialogWindow.setPreference()
โ
Retrieve that value inside the Jelly script
โ
Use it to query records or display dynamic content
Letโs walk through this ๐
๐งช Use Case: Display Assignment Group Name on a Popup
Say you're on the Incident form, and you want to show the Assignment Group name in a dialog when a button is clicked. Instead of hardcoding, letโs do it dynamically via Jelly.
๐ก UI Action Script
This code grabs the assignment_group from the form and passes it into a GlideDialogWindow:
function openAssignmentGroupDialog() {
var groupId = g_form.getValue('assignment_group');
alert(groupId); // optional: for debug
var dialog = new GlideDialogWindow('attendee_notifications_popup'); // name of your UI Page
dialog.setTitle('Assignment Group Info');
dialog.setPreference('assignment_group_sys_id', groupId); // pass value to UI Page
dialog.render();
}
๐ฅ๏ธ UI Page (Jelly Code)
Inside your UI Page (attendee_notifications_popup), you can retrieve the passed value like this:
<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide">
<!-- Step 1: Get sys_id from dialog preference -->
<g:evaluate var="jvar_groupId">
RP.getWindowProperties().get('assignment_group_sys_id');
</g:evaluate>
<!-- Step 2: Get group name using sys_id -->
<g:evaluate var="jvar_groupName">
var name = '';
var gr = new GlideRecord('sys_user_group');
if (gr.get('${jvar_groupId}')) {
name = gr.getValue('name');
}
name;
</g:evaluate>
<!-- Step 3: Display the output -->
<p><strong>Assignment Group Name:</strong> ${jvar_groupName}</p>
<p><strong>Assignment Group sysId:</strong> ${jvar_groupId}</p>
</j:jelly>
๐ง Key Concepts
dialog.setPreference('key', value) lets you pass variables into the popup.
Inside the Jelly script, use RP.getWindowProperties().get('key') to retrieve that value.
This method works great for dynamic forms, filtering, lookups, or even passing multiple values.
๐ Where Can You Use This?
Showing related data (like group info, user profile, or incident details) inside a modal
Filtering results dynamically inside the popup
Preloading fields in a form or wizard UI Page
Triggering approval or notification dialogs with dynamic context
๐โโ๏ธ Let Me Know Ifโฆ
Youโd like a full XML sample for import
You want to do this for multiple values
Youโre struggling with glide lists or reference fields inside Jelly
Hope this helps you make your UI Pages more dynamic and reusable ๐
If you found it helpful, drop a ๐ or share it with someone learning ServiceNow!
- 383 Views