UI Macro to popup a caller's CI list

swilson
Tera Expert

I created this UI macro and thought it may be of use to others. It creates an icon next to the Caller field on the Incident form that will pop up a list of CI's that are assigned to the caller. It's very similar to the 'Show related incidents' pop up, in fact I just copied that UI macro as a starting point for this one.

In addition to creating the UI macro, you will also need to set the Attributes field on the incident.caller_id field to:


ref_contributions=user_show_incidents;user_show_assigned_ci


UI Macro

Name: user_show_assigned_ci
XML:


<?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="Packages.com.glide.util.Guid.generate(this);" />
<j:set var="jvar_n" value="show_cis_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}"
field="${ref}"
onclick="showRelatedCIList('${ref}'); "
title="${gs.getMessage('Show related configuration items')}"
image="images/icons/cmbd_ci.gifx"/>


// show related list
function showRelatedCIList(reference) {
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField);
var url = 'cmdb_ci_list.do?&amp;sysparm_query=assigned_to=' + v;
var w = getTopWindow();
w.popupOpenFocus(url, 'related_list', 950, 700, '', false, false);
}
</j:jelly>
</xml>

11 REPLIES 11

robertgarza
Tera Contributor

Do you have any screen shots of this?


Here's this code again. There's an extraneous XML tag at the end of the previous example and so it won't work. I also attached some screen shots.

<?xml version="1.0" encoding="utf-8"?>




field="${ref}"
onclick="showRelatedCIList('${ref}'); "
title="${gs.getMessage('Show related configuration items')}"
image="images/icons/cmbd_ci.gifx"/>

<script></script>// show related list
function showRelatedCIList(reference) {
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField);
var url = 'cmdb_ci_list.do?&sysparm_query=assigned_to=' + v;
var w = getTopWindow();
w.popupOpenFocus(url, 'related_list', 950, 700, '', false, false);
}




Not applicable

Attempted to use this. The icon shows up on the incident form but everything starting with

function showRelatedCIList(reference) {

shows up as text to the right of the icon. Is there something I am missing.


swilson
Tera Expert

Something seems to get lost in the translation. The xml posted is missing the 'script', '/script' tags around the javascript function and also has a '/xml' tag at the end which should not be there. I attached a file 'user_show_assigned_ci.txt' that contains xml that I just tried in demo and works.