ThingWorx Model Definition in Composer > Modeling > Things > Alerts > Retrieving Threshold Information from Alerts
Retrieving Threshold Information from Alerts
The limit, maximum, minimum, etc values are stored within the alertAttributes infotable returned by the GetAlertDefinition service.
To access the specific values within the infotable, a wrapper service is required.
Example
Service retrieving limit value from an Above alert type on an INTEGER property:
Inputs
Outputs
propertyName : STRING
result: INTEGER
* 
The result type must match the type of the attribute returned. For this example, the result is an INTEGER.
alertName : STRING
Script Example
// These parameters have been parameterized into "alertName" and
// "propertyName" parameters at the service level. If these values
// will not change, they can be hard coded instead.
var params = {
alertName: alertName /* STRING */,
property: propertyName /* STRING */
};

// Retrieve the Alert Definition
var alertDef = me.GetAlertDefinition(params)

// Safety check on result from GetAlertDefinition()
if (alertDef != null && alertDef.rows.length > 0) {

// There should only be one row returned by GetAlertDefinition()
var alertProps = alertDef.rows[0];

// Safety check on alertAttributes infotable.
if (alertProps.alertAttributes != null && alertProps.alertAttributes.rows.length > 0) {
// Return the "limit" property from the alertAttributes table.
var result = alertProps.alertAttributes.rows[0].limit;
} else {
// The alertAttributes infotable was undefined or empty. This logs an error, but
// does not change the value returned. (Service returns no value.)
logger.error("AlertAttributes was null/empty!");
}
} else {
// The Alert Definition was empty.
// This is most commonly caused by invalid alertName/propertyName.
logger.error("Result from GetAlertDefinition was null/empty!");
Related Links
Was this helpful?