How to trigger Event Field Mapping from Event Rule in ServiceNow?

Abdulrajak Sha1
Tera Contributor

Hi,

 

We want to update Alert severity and assignment group based on the incoming event’s Additional Information field.

The Additional Information contains the Batch Job CI (cmdb_ci_batch_job) details. In the Batch Job CI, we define the severity and assignment group that should be applied to the Alert.

To achieve this, we created:

  • An Event Rule

  • An Event Field Mapping (want to update Alert record)

The Event Rule is triggering correctly and the Alert is created, but Event Field Mapping is not triggering at all:

  • Severity remains unchanged

  • Assignment group remains empty

  • No logs appear even when using gs.log() in the mapping script

Could someone please help explain how to trigger Event Field Mapping from an Event Rule, or if any additional configuration is required?

 

AbdulrajakSha1_0-1765994296763.png

 

AbdulrajakSha1_2-1765994405390.png

 

(function execute(eventGr, originalEventSysId, fieldMappingRuleName) {

    var sev = 4;

    try {
        var info = eventGr.getValue('additional_info');
        if (!info)
            gs.log('additional_info is EMPTY - Severity');
        return sev;

        var json = JSON.parse(info);
        gs.log('Parsed JSON=' + JSON.stringify(json));

        var name = json.name;

        var gr = new GlideRecord('cmdb_ci_batch_job');
        gr.addQuery('name', name);
        gr.query();

        if (gr.next()) {
            var s = (gr.u_alert_severity + '').toLowerCase();
            if (s == 'critical') sev = 1;
            else if (s == 'major') sev = 2;
            else if (s == 'minor') sev = 3;
            else sev = 4;
        }

    } catch (e) {
        gs.error('Alert Severity Mapping Error: ' + e);
    }

    return sev;

})(eventGr, originalEventSysId, fieldMappingRuleName);

 

Thank you

0 REPLIES 0