How to show list of open incidents using UI macro in catalog item?

bbf3562
Kilo Guru

I know pretty much the only way to show list of open incidents based on assignment group that user selected in catalog item is use UI macro. Does anyone know or have example codes for that? I just want a list of open incident tickets with each of them have clickable link to go to ticket form.

1 ACCEPTED SOLUTION

Hi Frank,



The script should be updated as below and then you will get those many records.


also add log statement to print that



<g:evaluate var="jvar_gr" object="true">


gs.log('Assignment group sys id is: ' + jelly.jvar_assignmentGroup_sys_id);


  var gr = new GlideRecord("incident");


    gr.addQuery("assignment_group", jelly.jvar_assignmentGroup_sys_id); // query incident table with this assignment group


    gr.query();


    gr;


</g:evaluate>



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Frank,



have following code in UI Page of catalog item



UI Page Code:


Name of ui page: incident_show


HTML Section:



<?xml version="1.0" encoding="UTF-8"?>


<j:jelly trim="false" xmlns:g="glide" xmlns:g2="null" xmlns:j="jelly:core"


xmlns:j2="null">


<j:set var="jvar_assignmentGroup_sys_id" value="${RP.getWindowProperties().get('assignmentGroupSysId')}" />



<g:evaluate var="jvar_gr" object="true">


    var gr = new GlideRecord("incident");


    gr.addQuery("assignment_group", ${jvar_assignmentGroup_sys_id}); // query incident table with this assignment group


    gr.query();


    gr;


</g:evaluate>



<j:while test="${jvar_gr.next()}">


  <tr>


  <td><a href="incident.do?sys_id=${jvar_gr.getValue('sys_id')}">${jvar_gr.getValue('number')}</a></td>


  </tr>


</j:while>


</j:jelly>



Call this UI page on change of assignment group field on catalog item.



var dialog = new GlideDialogWindow("incident_show");  


dialog.setTitle("Incident Details");  


dialog.setPreference("assignmentGroupSysId", g_form.getValue('assignment_group')); // use variable name here  


dialog.render();



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,


I tried your code and it end up "page not found". Here a screenshot,


find_real_file.png


Here is UI macro codes,


find_real_file.png


And then here is catalog item onChange script,


find_real_file.png


Hi Frank,



As mentioned in my comment I have created UI page and not UI macro.


Can you test it with UI page



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ok I just changed to UI Page instead, this is what I got,


find_real_file.png


It should show 16 incident tickets.



This is what I add in UI page,


find_real_file.png