viewing a related list from a pop-up window

dh4234
Kilo Expert

Is it possible to view a related list in a reference field's pop up window? For example when our PC team receives a task to build a PC they need to be able to select the software that was installed. It would be a lot easier for them if they could do it all from inside the task rather than find the PC in the CMDB and updating the record from there.

3 REPLIES 3

Not applicable

I put together a basic UI Macro that I think might get you what you need. Here is a screen shot of what it looks like from the Incident form - http://screencast.com/t/OLhxytcJ - notice related lists are included and editable from the pop-up.

1. Name the UI Macro - show_ci_and_related_lists
2. Add the following code to the UI Macro



<?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="add_edit_ci_${jvar_guid}:${ref}"/>
<a id="${jvar_n}" onclick="addEditCIPop('${ref}')">
<img border="0" src="images/icons/user_profile.gifx" title="${gs.getMessage('Add/Edit Configuration Item')}" alt="${gs.getMessage('Add/Edit Configuration Item')}"/>
</a>

<script>
//OnClick function for UI macro
function addEditCIPop(reference){
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField);

//If CI field is empty then pop open an 'Add CI' dialog
if(v == ''){
var dialog = new GlideDialogForm('Add CI', 'cmdb_ci', setCIField);
dialog.setSysID('-1'); //Pass in -1 to create a new record
}
//Else pop open an 'Edit CI' dialog for the populated ci record
else{
var dialog = new GlideDialogForm('Edit Configuration Item', 'cmdb_ci', setCIField);
dialog.setSysID(v); //Pass in reference sys_id to edit record
}
dialog.addParm('sysparm_view', 'default'); //Specify a form view
dialog.render(); //Open the dialog

//Callback function executed from dialog submit
function setCIField(action, sys_id, table, displayValue){
//Set the user field with the popup ci
g_form.setValue(referenceField, sys_id);
}
}
</script>
</j:jelly>


3. Add the following attribute to the dictionary on the Configuration item field - ref_contributions=show_ci_and_related_lists


See this SNCGuru post for full details on this solution.

http://www.servicenowguru.com/system-ui/ui-macros/adding-referenced-records-leaving-form/

This bypasses the regular hover icon entirely and uses a custom UI macro icon to show a different popup. It will work for a field on a form, but it's not going to help you when working in a list or anywhere else that the macro cannot be shown.

The major difference (besides changing the labels and table name) in the script above and the SNCGuru solution is that the script above shows related lists in the dialog by removing this line of code...



dialog.addParm('sysparm_form_only', 'true'); //Remove related lists


dh4234
Kilo Expert

Thanks... This is what I was looking for.