Issue with Customizing Alarm Management API for Event Severity Mapping

JamesGreen
Giga Contributor

Hi everyone,

I’ve been working with the Alarm Management Open API in ServiceNow and am trying to customize the mapping for the event severity. Specifically, I want to override the severity field during event creation to always set the severity to "Critical" when certain conditions are met. However, the severity is not updating as expected, and I’m not sure what I'm missing in my customization.

 

Here’s what I’ve done so far:

  • I extended the AlarmAPIProcessor class to override the default field mapping for severity using the mapCreateAlarmObjectToEvent function.
  • I ensured the function is called by replacing the default function from AlarmAPIProcessorOOB.

Here's my code for overriding the severity field mapping:

 

var AlarmAPIProcessor = Class.create();
AlarmAPIProcessor.prototype = Object.extendsObject(AlarmAPIProcessorOOB, {
    // Overriding mapCreateAlarmObjectToEvent to change the severity
    mapCreateAlarmObjectToEvent: function(eventGr, eventObject){
        // Custom mapping logic for severity field
        if (eventObject.alarmType == 'SystemFailure') {
            eventGr.severity = "Critical";  // Force severity to Critical if event is a system failure
        }
    },
    
    type: 'AlarmAPIProcessor'
});

 

Even though the code should update the severity field when the alarm type is "SystemFailure," the severity is not being set as "Critical" in the event records.

 

I’ve also made sure that my custom function is correctly overriding the default, but it still doesn’t seem to work. The field mapping is not being applied, and I can't figure out why. Has anyone encountered a similar issue or knows what might be going wrong?

For reference, I’m using the (https://www.servicenow.com/docs/bundle/yokohama-api...) for my implementation.

Thanks in advance for any help!

1 REPLY 1

Bert_c1
Kilo Patron

In the mapCreateAlarmObjectToEvent function in the 'AlarmAPIProcessorOOB' script include it is defined as:

    mapCreateAlarmObjectToEvent: function(alarmObject, eventGr) {},
could you problem be the reversal of the two parameters in your:
    mapCreateAlarmObjectToEvent: function(eventGr, eventObject){

function definition?