Custom Related Incidents UI Macro with Active Filter and Specific View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 01:46 PM
I am currently working on creating a revised version of the "user_show_incidents" UI macro. Everything I've tried has either been completely disregarded by the system or has made it stop working.
My goal is to only show the related incidents in a specific list view I created called "condensed" and to only display the active incidents.
What I did was clone it and make my adjustments to "user_show_incidents_condensed" - added my active=true filter and made the sysparm_view = condensed. I've tried numerous modifications of this but no luck.
I also ensured the attribute to the caller field on incident is updated to my new one: "ref_contributions=user_show_incidents_condensed"
Revised UI Macro 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="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>
function showRelatedList(reference) {
var s = reference.split('.');
var referenceField = s[s.length - 1];
var v = g_form.getValue(reference);
var w = new GlideDialogWindow('show_list');
w.setTitle('Related incidents');
// Change the sysparm_view to 'condensed' instead of 'default'
w.setPreference('table', 'incident_list');
w.setPreference('sysparm_view', 'condensed');
// Filter out only active records
// sysparm_query = "active=true^[referenceField]=[value]"
w.setPreference('sysparm_query', 'active=true^' + referenceField + '=' + v);
w.render();
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 09:47 PM
any browser console error when you click that icon?
Is the view name condensed correct?
what came in alert for this?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 09:56 PM
try this
w.setPreference('sysparm_query', referenceField + '=' + v + '^active=true');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 10:50 PM
@Daniel Arnold - Your code is working fine in my PDI in Yokohama version. Except the condensed view as I don't have one. But if I update to other views available then it works fine.
Please try clear your browser cache and check.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 08:43 AM
So what I find happens with the list view is if i am currently using "mobile" view for example, it will display the popup in that view. Essentially, it only displays in whatever view you are currently using. I'd like it to force the popup to use a certain view regardless of what the user has been using most recently.