How to show if configuration item have outage record in the incident form related list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
How to show 'outage record' if configuration item have outage entry in the incident form related list.
I have tried script on sys_relationship but not works but the record will shows Run Query Diagnostics. Please refer below screenshot and suggest on this requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
Hi @ashok17
gr.addNullQuery() is the supported way to null check. This would work with correct data. Using current.addQuery('sys_id', 'NULL'); in ServiceNow does not work as expected because the string 'NULL' is treated as a literal text value rather than a database null value. This query will return zero records.
Refer this article to know how it works: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1543644
(function refineQuery(current, parent) {
// If the Incident's Configuration Item field is empty, stop and return nothing.
if (!parent.cmdb_ci) {
current.addNullQuery('sys_id');
return;
}
// If a CI exists, find matching Outages
current.addQuery('cmdb_ci', parent.cmdb_ci);
})(current, parent);
If that specific Configuration Item has active outages in the cmdb_ci_outage table, they will display
Test
Navigate to Incident record that you know has a Configuration Item populated
Right-click the form header -> Configure -> Related Lists.
Locate Outage Visibility on incident form in the left column, move it to the right column, and click Save.
Scroll down to your new related list.Hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday