The CreatorCon Call for Content is officially open! Get started here.

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

pritam8
Kilo Expert

Hi,



Thanks for sharing, But i am facing issues after implementation.



in dictionary attributes : ref_contributions=user_show_cis;user_show_incidents;



then I am getting two icons but both are redirecting to incident list.



if I am writing



in dictionary attributes : ref_contributions=user_show_incidents;user_show_cis;



then I am getting two icons but both are redirecting to   CMDB CI's list.



Please help me on above issue.



Thanks,


Pritam


Paul Curwen
Giga Sage

So many missteps and errors on this post.

 

If you are having issues follow these simple steps:

 

1. Create a UI Macro 

 

Set Name field to: match_cis

 

In the XML field paste the following code: 

 

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

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

     <j2:set var="jvar_n" value="getUserAssets_${ref}"/>

     <a id="${jvar_n}" onClick="getUserAssets()" title="Lookup user assets" alt="Add me" tabindex="0" class="btn btn-default icon-hardware"></a>

     <script>

 

      function getUserAssets() { 

 

       var refurl = reflistOpenUrl('incident.cmdb_ci', 'incident.cmdb_ci', 'cmdb_ci', 'cmdb_ci', 'null', 'false', '');  

       var url = 'assigned_to=' + g_form.getValue('caller_id');      

             var refurlquery = refurl + url;          

             popupOpenStandard(refurlquery, 'lookup');

 

             }

     </script>

 

</j:jelly>

 

Save the form. It will look something like below (not all code shown in image) 

 

match cis.PNG

 

3. On the Incident form right-click the caller_id field and select 'Configure Dictionary'

 

select.PNG

 

4. In the Attibutes field paste the following

 

encode_utf8=false,ref_contributions= match_cis

 

Important ote: if you already have ref_contribution in the Attributes field simple type ; at the end of what is already there and and add match_cis

 

dict.PNG

 

5. Test on incident form by populating Caller ID field with a user that has config items and you should see the new field decorator as below, click it and select any CI it will then populate the selected CI on the cmdb-ci field: 

 

uimacro.PNG

 

Hope that helps everyone avoid the confusion 🙂

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul