user_show_incidents attribute "Show related incidents"

Andrew18
Giga Expert

Hello,

This is probably simple but struggling to make the changes to the Macro.

I've been asked to update the "show related incidents" button next to the caller so instead of it pointing to the incident table it points to the task and show's all related records including requested_by and requested_for. 

Anyone know how I go about doing this?

8 REPLIES 8

Bhaba
Tera Expert

Hi Andrew,

Follow the below steps:

  1. In the form, right-click the label for the reference field and select Configure Dictionary.
  2. Add the ref_contributions=user_show_incidents dictionary attribute in the Attributes field.
  3. Click Update.

    The form reopens and the related incidents icon appears beside the field on the right.

Hope this helps you. Mark the answer helpful if this helped you.

Thanks

Hi Bahba, thanks for coming back to me. I've found this I'm just trying to find a way to have it pointing to the task table opposed to the Incident table so I can bring up more records.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so what's your requirement?

it should point to incident or task?

The records should be filters based on what query?

Regards
Ankur

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

Hi,

if you want to point to task table then update as this

<?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_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}" 
  onclick="showRelatedList('${ref}'); "
  title="${gs.getMessage('Show related incidents')}" image="images/icons/tasks.gifx" icon="icon-tree-right"/>

<script>
// show related list 
// todo: should be part of the PopupWindow class
// todo: needs new stack name
function showRelatedList(reference) {
    var s = reference.split('.');
    // Get the field name which is always last
      var referenceField = s[s.length - 1];
      var v = g_form.getValue(reference);
      var w = new GlideDialogWindow('show_list');
      w.setTitle('Related incidents');
      w.setPreference('table', 'task_list');
      w.setPreference('sysparm_view', 'default');
      w.setPreference('sysparm_query', referenceField + '=' + v); // ensure you give correct query here
      w.render();
}

</script>
</j:jelly> 

Regards
Ankur

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