Sys_id of incident inside UI Macro

coolek
Giga Expert

Hello,

I have created UI macro. This macro is running on the incident form and only find all notifications whose belong to current incident.

But I need the sys_id of the incident changes dynamicaly. Is any choice that this provides me? My code of UI macro is below this text.

Thank you.

<?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="jvar_emails" object="true">

      var gr = new GlideRecord("sys_email");

      gr.addQuery('instance', 'e8e875b0c0a80164009dc852b4d677d5');

      gr.orderBy('sys_created_on');

      gr.query();

      gr;

</g:evaluate>

<table>

    <tr>

        <th>Email to</th>

        <th>Subject</th>

        <th>Date</th>

    </tr>

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

            <tr>

                  <td>${HTML:jvar_emails.getValue('recipients')}</td>

                  <td>${HTML:jvar_emails.getValue('subject')}</td>

                  <td>${HTML:jvar_emails.getValue('sys_created_on')}</td>

          </tr>

    </j:while>

  </table>

</j:jelly>

1 ACCEPTED SOLUTION

Hi Harel,



Thank you for your reply.


Yes I tried current.sys_id and g_form.getUniqueValue () and this was not working.


I configure the UI macro in the incident form where are the tabs (notes, related records ...) on this place I create a new tab and calls formatter that uses my UI macro.



But I solved it with parse URL, concrete I need sys_id from url. Code looks like this.



<g:evaluate var="sys_id">


          var sys_id = RP.getParameterValue("sys_id");


          sys_id;


</g:evaluate>



<g:evaluate var="jvar_emails" object="true" jelly="true">


        var gr = new GlideRecord("sys_email");


        gr.addQuery('instance', jelly.sys_id);


        gr.orderBy('sys_created_on');


        gr.query();


        gr;


</g:evaluate>


View solution in original post

3 REPLIES 3

oharel
Kilo Sage

Hi Petr,



Did you try current.sys_id or g_form.getUniqueValue()?


Also, where do you configure the ui macro on the form?


harel


Hi Harel,



Thank you for your reply.


Yes I tried current.sys_id and g_form.getUniqueValue () and this was not working.


I configure the UI macro in the incident form where are the tabs (notes, related records ...) on this place I create a new tab and calls formatter that uses my UI macro.



But I solved it with parse URL, concrete I need sys_id from url. Code looks like this.



<g:evaluate var="sys_id">


          var sys_id = RP.getParameterValue("sys_id");


          sys_id;


</g:evaluate>



<g:evaluate var="jvar_emails" object="true" jelly="true">


        var gr = new GlideRecord("sys_email");


        gr.addQuery('instance', jelly.sys_id);


        gr.orderBy('sys_created_on');


        gr.query();


        gr;


</g:evaluate>


I am glad you figured it out.