Is the alert example code on this page still valid as of 8.4?
At the bottom of this page there is an example of how to add or edit an alert for a given property. However when I try and implement this I get the error: "Error executing service AlertAddUpdate. Message :: Alert Attributes For [Above] are not valid - See Script Error Log for more details."
The only attributes we need to set are the limit and the limit inclusive if I'm correct, so why would I be getting this error message? I have changed the property variable name to a property on the thing where I am implementing this service.
// Create the Attributes Infotable for AddOrUpdateAlert call
var params = {
infoTableName: "alertAttr" /* STRING */
};
var attrs = Resources["InfoTableFunctions"].CreateInfoTable(params);
// Define the fields required by an Above type Alert for an INTEGER field (not the values!)
// limit - Minimum value at which the alert will trigger.
var field = new Object();
field.name = "limit";
field.baseType = 'INTEGER';
attrs.AddField(field);
// limitInclusive - Is the condition Greater than (>) or Greater than or equal (>=)?
field.name = "limitInclusive";
field.baseType = 'BOOLEAN';
attrs.AddField(field);
// Define the new Alert values and add the row to the table.
var row = new Object();
row.limit = 5; // Alert will trigger when field >=5
row.limitInclusive = true; // Alert includes 5
attrs.AddRow(row);
// Call the AddOrUpdateAlert Service
var params = {
alertType: "Above" /* STRING */,
alertName: "MyAlert" /* STRING */,
property: "Sensor_Value2" /* STRING */,
attributes: attrs /* INFOTABLE */,
priority: 1 /* INTEGER */,
persistent: true /* BOOLEAN */,
enabled: true /* BOOLEAN */
};
me.AddOrUpdateAlert(params);
This is my code just for reference.
Thanks,
Jon

