๐Ÿ”„ Passing Values from UI Action to Jelly UI Page in ServiceNow

Siddhesh Jadhav
Kilo Sage

 

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!

 

0 REPLIES 0