6.3 Getting and Setting Properties

To get any property set by the underlying management system, use either the dot notation alarm.property or the array notation alarm[property]. The array notation might be necessary if the property name itself is a reserved word of JavaScript, such as “class”, “in”, or “function.” For example:

var alarm = formula.Elements.alarms[0] // Assume at least one!
writeln( 'Alarm: ' + alarm + ' is attached to ' + alarm.element )

To set a property, assign a value to the right-hand portion of an assignment operation. The two ways to denote property accessors are using dot (.) notation and using array notation ([]). Assigning a property to an alarm exposed in Operations Center scripting engine might result in an actual transaction against a managed resource.

An example:

// Warning, this adds some random field values to a random alarm
// DO NOT use on a production system!
try
{
   var alarm = formula.Elements.alarms[0] // Assume at least one!
   alarm.foo = 'bar'
   alarm[ 'class' ] = 'Zinger'
}
catch( Exception )
{
   formula.log.warn( 'Could not modify alarm: ' + Exception )
}