AddOrUpdateAlert for "In Range" OR "Out Range",Alert Attributes For [InRange] are not valid
Hi everyone,
I want to use AddOrUpdateAlert to change the property Alert in service,I am using below code :
//Create the Attributes Infotable for AddOrUpdateAlert call
var params = {
infoTableName: "alertAttr" /* STRING */
};
var attrs = Resources["InfoTableFunctions"].CreateInfoTable(params);
// limit - Minimum value at which the alert will trigger.
var field = new Object();
field.name = "minimum";
field.baseType = "NUMBER";
attrs.AddField(field);
// limitInclusive - Is the condition Greater than (>) or Greater than or equal (>=)?
field.name = "minimumInclusive";
field.baseType = 'BOOLEAN';
attrs.AddField(field);
// limit - Maximum value at which the alert will trigger.
field.name = "maximum";
field.baseType = "NUMBER";
attrs.AddField(field);
// limitInclusive - Is the condition Greater than (>) or Greater than or equal (>=)?
field.name = "maximumInclusive";
field.baseType = 'BOOLEAN';
attrs.AddField(field);
var row = new Object();
row.minimum = 2; // Alert will trigger when field <2
row.minimumInclusive = true;
row.maximum = 9; // Alert will trigger when field >=9
row.maximumInclusive = false;
attrs.AddRow(row);
me.AddOrUpdateAlert({
property: "temp" /* STRING */,
alertType: "InRange" /* STRING */,
alertName: "stateAlert" /* STRING */,
description: "myTestAlert" /* STRING */,
enabled: true /* BOOLEAN */,
priority: 1 /* INTEGER */,
attributes: attrs /* INFOTABLE */,
persistent: true /* BOOLEAN */
});
Error Message :Error executing service alertAdd. Message :: Alert Attributes For [InRange] are not valid - See Script Error Log for more details
I was able to do this for an Above and Below alert but can't get it to work with an "InRange" or "OutOfRange" alert type refert to this Article:CS230216 - What is the Expected Format of the Attributes InfoTable for the AddOrUpdateAlert Service on ThingWorx? (ptc.com)
Anyone help with it ?
Thanks!

