Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hi ,
I am trying to create dynamic alerts , it is working for "Above" , "Below" , "Equal To" etc. but the same logic is not working for "in Range" and "Out Range".
I am using below code :
var params = {
infoTableName: "alertAttr" /* STRING */
};
var attrs = Resources["InfoTableFunctions"].CreateInfoTable(params);
var field = new Object();
field.name = "minimum";
field.baseType = 'NUMBER';
attrs.AddField(field);
field.name = "minimumInclusive";
field.baseType = 'BOOLEAN';
attrs.AddField(field);
field.name = "maximum";
field.baseType = 'NUMBER';
attrs.AddField(field);
field.name = "maximumInclusive";
field.baseType = 'BOOLEAN';
attrs.AddField(field);
var row = new Object();
row.minimum = MinValue;
row.minimumInclusive = true;
row.maximum = MaxValue;
row.maximumInclusive = true;
attrs.AddRow(row);
Things[thingName].AddOrUpdateAlert({
alertType: DeviationType /* STRING */,
alertName: AlertName /* STRING */,
property: Property /* STRING */,
description: undefined /* STRING */,
attributes: attrs /* INFOTABLE */,
priority: Priority /* INTEGER */,
persistent: true /* BOOLEAN */,
enabled: true /* BOOLEAN */
});
Can you please help with it ?
Chahat Gupta
Hi @ChahatGupta,
Can you try with the following code:
var params = {
infoTableName : "InfoTable",
dataShapeName : "NumberRangeAlert"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(NumberRangeAlert)
var table = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
table.minimum = 5;
table.minimumInclusive = true;
table.maximum = 10;
table.maximumInclusive = true;
var params = {
alertType: "OutOfRange" /* STRING */,
alertName: "temp3" /* STRING */,
property: "MyIntProperty" /* STRING */,
description: undefined /* STRING */,
attributes: table /* INFOTABLE */,
persistent: true /* BOOLEAN */,
priority: 1 /* INTEGER */,
enabled: true /* BOOLEAN */
};
me.AddOrUpdateAlert(params);
Please use the datashapes defined as system objects. You will find NumberRangeAlert, IntegerRangeAlert, DateTimeRangeAlert, LongRangeAlert.