Add "Show Related Incidents" to New Call form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2017 07:23 AM
So I've added the reference to the below UI Macro on the New Call form in the Caller field. This is the related incidents UI Macro used on the Incident form. On the New Call form, it pops up and show the Related Incidents, but it shows it for ALL callers and not just the Caller on the New Call form. Now, I think this is because on the Incident form the Caller field has a value of 'caller_id' and on the New Call form the Caller field is 'caller'.
How can I modify the below UI Macro to work on the New Call form? I will obviously use Insert and stay to make a copy of this current macro and modify it for the New Call form.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2017 07:34 AM
- incident_list will be replaced with tablename_list
- sysparm_view will be replaced with any custom view if you have one or can be left as is.
- sysparm_query - You can build this on the UI to filter the records that you want to show. Copy the query from the filter and add it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2017 07:40 AM
Thanks for those preference explanations. I am already getting the right list, Incidents, and the view is fine, but I guess it's the query I am having issues with because it's pulling ALL Callers instead of the Caller on the New Call form. I can't tell what's in the variables referenceField and V as I don't know how to log them/view them.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2017 07:39 AM
Hi Steven,
You can try using below snippet.
<?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"/>
<script>
// show related list
function showRelatedList(reference) {
try {
var displayValue = g_form.getDisplayBox(reference).value;
var title = 'Showing records related to: ' + displayValue;
var s = reference.split('.');
var referenceField = s[s.length - 1];
if (referenceField == 'caller')
{
referenceField = 'caller_id';
}
var query = referenceField + '=' + g_form.getValue(reference);
var gdw = new GlideModal('show_list');
gdw.setTitle('Related Incidents');
gdw.setSize(750);
gdw.setPreference('table', 'incident_list');
gdw.setPreference('sysparm_query', query);
//gdw.setPreference('title', 'A New Title');
gdw.render();
}
catch (e) {
jslog('error showing related list');
jslog(e);
}
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2017 07:53 AM
This helped. I just took your IF statement around 'caller' and 'caller_id' and now the list is returning only Incidents from the proper Caller on the New Call form.
How can I edit the query to add 'state=1'? I am still using the original UI Macro I listed above:
w.setPreference('sysparm_query', referenceField + '=' + v + '^ANDstate=1');
EDIT:
I just had to remove AND from the query above and it works:
w.setPreference('sysparm_query', referenceField + '=' + v + '^state=1');
Thanks for your help!
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven