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

Siddhesh Jadhav
Kilo Sage
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