Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

UI page pop up show list view

keshav77
Tera Contributor

Hi ALL

 

I am trying to create one ui page which will pop up once the user select the configuration item value in catalog variable the  ui page will pop-up and shows all incident which is having those have selected configuration item I am using Iframe to get this. But what is happening the sys_id is some how not going to the  ui page  and it is not rendering the result I want. 

BELOW IS MY CLIENT SCRIPT AND UI PAGE SCRIPT 

UI PAGE SCRIPT-- 

 

<?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="ci_sys_id" expression="RP.getWindowProperties().get('ci_sys_id')" />

    <body>
        <script>
            // Alert to confirm the CI sys_id is received
            alert("CI sys_id received: ${ci_sys_id}");
        </script>

        <!-- Debug message on the page -->
        <j:if test="${ci_sys_id == null}">
            <div style="color: red; font-weight: bold; padding: 10px;">CI Sys ID is NULL!</div>
        </j:if>
        <j:if test="${ci_sys_id != null}">
            <div style="color: green; font-weight: bold; padding: 10px;">CI Sys ID: ${ci_sys_id}</div>
        </j:if>

        <g:ui_form>
            <div style="height:600px; padding: 10px;">
                <iframe
                    id="incident_list_frame"
                    src="incident_list.do?sysparm_query=cmdb_ci=${ci_sys_id}&amp;sysparm_view=Default&amp;sysparm_clear_stack=true"
                    width="100%" height="100%" frameborder="0"
                    sandbox="allow-scripts allow-forms allow-same-origin allow-popups">
                </iframe>
            </div>

            <div style="padding: 10px; text-align: center;">
                <button onclick="returnQuery()" class="btn btn-primary">Get Query</button>
                <button onclick="cancelDialog()" class="btn btn-default">Cancel</button>
            </div>
        </g:ui_form>
    </body>
   
    <script>
        // Function to return the query to the parent form
        function returnQuery() {
            var dialog = GlideDialogWindow.get();
            var frame = document.getElementById('incident_list_frame');
            var frameUrl = frame.contentWindow.location.href;

            var queryParam = 'sysparm_query=';
            var queryString = '';

            if (frameUrl.indexOf(queryParam) !== -1) {
                queryString = frameUrl.substring(frameUrl.indexOf(queryParam) + queryParam.length);
                queryString = decodeURIComponent(queryString);
            }

            var parentGForm = dialog.getParentGForm();
            if (parentGForm) {
                parentGForm.setValue('u_filter_variable', queryString);
            }
           
            dialog.destroy();
        }
       
        // Function to close the dialog
        function cancelDialog() {
            GlideDialogWindow.get().destroy();
        }
    </script>
</j:jelly>  
 
On change client script--
 
function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

  var dialog = new GlideDialogWindow('incident_list_ui_page');
  dialog.setTitle('Incident List');
  dialog.setPreference('ci_sys_id', newValue); // pass CI sys_id
  dialog.render();
} any suggetions  on this
1 REPLY 1

Community Alums
Not applicable

Hi @keshav77 ,

The issue is with how you’re retrieving the value in the UI Page. When you use dialog.setPreference('ci_sys_id', newValue), the value is not accessed with RP.getWindowProperties().get(). Instead, it becomes available as a Jelly variable with the prefix jvar_.

So instead of trying to evaluate it with:

<g:evaluate var="ci_sys_id" expression="RP.getWindowProperties().get('ci_sys_id')" />

you should simply reference it like this:

${jvar_ci_sys_id}


So just replace all references to ci_sys_id with jvar_ci_sys_id in your UI Page. That will fix the problem, and your sys_id will be passed correctly to the iframe.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.