How to show if configuration item have outage record in the incident form related list.

ashok17
Tera Contributor

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.

 

ashok17_0-1779982490257.png

 

2 REPLIES 2

PoonkodiS
Giga Sage

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 

  1. Navigate to Incident record that you know has a Configuration Item populated 

  2. Right-click the form header -> Configure -> Related Lists.

  3. Locate Outage Visibility on incident form in the left column, move it to the right column, and click Save.

  4. Scroll down to your new related list.Hope it helps!

PoonkodiS
Giga Sage

PoonkodiS_0-1779986710822.pngPoonkodiS_1-1779986752160.png