BLOG: Filter Update for Affected CIs Related list Add button on Outage Form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2026 12:09 AM
How to Add a Filter Condition to the “Add” List Popup in the Affected CIs Related List on the Outage Form (ServiceNow)
In ServiceNow, when working with the Outage form, the Affected CIs related list allows users to associate Configuration Items (CIs) with an outage.
When the Add button is clicked, ServiceNow opens a list popup inside a GlideModal that allows users to select CIs.
However, sometimes you may want to restrict which CIs appear in this popup by applying a filter condition (for example, only show CIs with Install Status = Installed).
This article explains how to intercept the popup URL and add a filter condition dynamically.
1. Locate the “Add” Button UI Action
On the Outage form, go to the Affected CIs related list.
Right-click the Add button.
Select Inspect (browser developer tools).
Locate the gsft_id attribute of the button or use the SN_Utils to locate.
Then open the UI Action in ServiceNow.
You will see a client-side script similar to the following in the Script field:
function openCmdbCIList() {
var gajax = new GlideAjax("AssociateCIToOutage");
gajax.addParam("sysparm_name", "getURL");
gajax.addParam("sysparm_id", g_form.getUniqueValue());
gajax.addParam("sysparm_add_to", "cmdb_outage_ci_mtom");
gajax.getXMLAnswer(openList);
}2. Understand How the List Popup Works
The returned URL is passed to the function openList(), which renders the modal popup.
function openList(url) {
var cmdbciModal = new GlideModal('outage_add_affected_cis');
cmdbciModal.setTitle(getMessage("Add Affected CIs"));
cmdbciModal.setWidth(1200);
cmdbciModal.setAutoFullHeight(true);
cmdbciModal.on('beforeclose', function() {
refreshAffectedCIs();
});
ScriptLoader.getScripts('/scripts/incident/glide_modal_accessibility.js', function() {
cmdbciModal.template = glideModalTemplate;
cmdbciModal.renderIframe(url, function(event) {
glideModalKeyDownHandler(event, cmdbciModal.getID());
});
});
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'styles/incident_glide_modal.css';
document.head.appendChild(link);
}This renders the list view inside an iframe, using the URL returned from the server.
Below is the sample URL which is getting returned when Configuration Class is Configuration Item
outage_add_affected_cis.do?sysparm_table=cmdb_ci&sysparm_add_to=cmdb_outage_ci_mtom&sysparm_stack=no&sysparm_parent_class=cmdb_ci&sysparm_view=associate_ci&sysparm_crSysId=178f7136f1bb22108bb2efdbde054c91&sysparm_crTable=cmdb_ci_service&sysparm_filter3. Modify the URL to Add a Filter Condition
To apply a filter condition, we intercept the URL and add a sysparm_query parameter.
Example: Filter only Installed CIs
Updated script:
function openCmdbCIList() {
var gajax = new GlideAjax("AssociateCIToOutage");
gajax.addParam("sysparm_name", "getURL");
gajax.addParam("sysparm_id", g_form.getUniqueValue());
gajax.addParam("sysparm_add_to", "cmdb_outage_ci_mtom");
gajax.getXMLAnswer(openList);
}
function openList(url) {
var urlObj = new URL(url, window.location.origin);
// Get table parameter
var table = urlObj.searchParams.get("sysparm_table");
// Apply filter only for cmdb_ci table
if (table == "cmdb_ci") {
urlObj.searchParams.set("sysparm_query", "install_status=1");
}
var finalUrl = urlObj.toString();
var cmdbciModal = new GlideModal('outage_add_affected_cis');
cmdbciModal.setTitle(getMessage("Add Affected CIs"));
cmdbciModal.setWidth(1200);
cmdbciModal.setAutoFullHeight(true);
cmdbciModal.on('beforeclose', function() {
refreshAffectedCIs();
});
ScriptLoader.getScripts('/scripts/incident/glide_modal_accessibility.js', function() {
cmdbciModal.template = glideModalTemplate;
cmdbciModal.renderIframe(finalUrl, function(event) {
glideModalKeyDownHandler(event, cmdbciModal.getID());
});
});
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'styles/incident_glide_modal.css';
document.head.appendChild(link);
}4. Refresh the Related List After Selection
After selecting CIs and closing the modal, the Affected CIs related list must refresh.
function refreshAffectedCIs() {
var listId = g_form.getTableName() + ".cmdb_outage_ci_mtom.outage";
var list = typeof GlideList2 !== "undefined" ? GlideList2.getByName(listId) : null;
if (list == null)
list = typeof GlideList !== "undefined" ? GlideList.get(listId) : null;
if (list != null)
list.refresh();
}5. Important Note
Although the Add button is the same, the table rendered in the popup can change depending on the CI class configuration.
For example, the list may load:
cmdb_cicmdb_ci_servicecmdb_ci_telco_circuitor other extended CI tables.
Therefore:
Always check the
sysparm_tableparameterEnsure the query is applied only to the correct table
- Though, the Query looks similar (for example: Installed Status = Installed) but the backend value will differ based on the
sysparm_tablei.e.,Configuration Class
Example:
if (table == "cmdb_ci") {
urlObj.searchParams.set("sysparm_query", "install_status=1");
}