π 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!
- 483 Views
