CI field Auto Population in the Alert record(em_alert)- Event Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
My requirement is that the CI field in the Alert record should get populated always. It should be populated based on the Node field. But currently if the Node field contains ci value that doesn't extend cmdb_ci_hardware then the CI value is not getting populated. If the CI in the Node field extends both hardware and a non-hardware class, then it should populate the CI that extends from the hardware class. Kindly help me solve my requirement. Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
hey @Narmadha PR
This behavior is expected due to how CI binding works when class constraints are involved. By default, if the matching CI does not extend cmdb_ci_hardware, it will be skipped based on your current logic or configuration.
You can handle this using a scripted CI binding logic (depending on your setup: Event Rule, Transform Map, or Business Rule (Before insert ) on Alert table).
Script -
(function executeRule(current, previous) {
try {
// 1. Validate input
if (!current.node) {
gs.info('[CI Binding] Node is empty, skipping CI population');
return;
}
var nodeValue = current.node.toString().trim();
var ciGR = new GlideRecord('cmdb_ci');
// 2. Flexible matching (name / fqdn / ip)
var qc = ciGR.addQuery('name', nodeValue);
qc.addOrCondition('fqdn', nodeValue);
qc.addOrCondition('ip_address', nodeValue);
ciGR.query();
var hardwareCI =" '';
var fallbackCI = ''";
// 3. Iterate through matches
while (ciGR.next()) {
var className = ciGR.getValue('sys_class_name');
// Prefer CI extending cmdb_ci_hardware
if (GlideDBObjectManager.get().isInstanceOf(className, 'cmdb_ci_hardware')) {
hardwareCI = ciGR.getUniqueValue();
gs.info('[CI Binding] Hardware CI selected: ' + ciGR.getDisplayValue());
break; // highest priority
}
// Store first non-hardware as fallback
if (!fallbackCI) {
fallbackCI = ciGR.getUniqueValue();
}
}
// 4. Final assignment
if (hardwareCI) {
current.cmdb_ci = hardwareCI;
} else if (fallbackCI) {
current.cmdb_ci = fallbackCI;
gs.info('[CI Binding] Fallback CI selected');
} else {
gs.info('[CI Binding] No matching CI found for Node: ' + nodeValue);
}
} catch (ex) {
gs.error('[CI Binding Error] ' + ex.message);
}
})(current, previous);
*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
hey @Narmadha PR
Hope you are doing well.
Did my previous reply answer your question?
If it was helpful, please mark it as correct ✓ and close the thread . This will help other readers find the solution more easily.
Regards,
Vaishali Singh
