Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to filter nested worknotes for multiple alerts and display in UI Page

Community Alums
Not applicable

Hi team,

Could you please helpme with this 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">
  <h3>Event table</h3>
  <g:evaluate var="jvar_sysId" expression="RP.getWindowProperties().sysparm_sysid"/>
  <g:evaluate jelly="true" object="true">

    var rec = new GlideRecord('em_alert');
    rec.addQuery('u_case', jelly.sysparm_sysid);
    rec.query();
    
    var alertSysIds = []; // Array to store alert sys_ids

    while (rec.next()) {
      alertSysIds.push(rec.sys_id.toString());
    }

    var gr = new GlideRecord("sys_journal_field");
    gr.addQuery("element_id", "IN", alertSysIds.join(','));
    gr.addEncodedQuery("valueLIKEdue to event");
    gr.addQuery("element", "work_notes");
    gr.query();
    gr;
  </g:evaluate>
  <table border="1">
    <tr><td colspan="2">Event Messages</td></tr>
    <tr>
      <th>Number</th>
      <th>Work Notes</th>
    </tr>
    <j:while test="${gr.next()}">
      <tr>
        <td>${rec.number}</td>
        <td>${gr.value}</td>
      </tr>
    </j:while>
  </table>
  <style>
    td, th{
      padding: 10px;
    }
  </style>
</j:jelly>

0 REPLIES 0