cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Unable to configure dynamic alerts for "In Range" and "Out Range" Deviation types

ChahatGupta
8-Gravel

Unable to configure dynamic alerts for "In Range" and "Out Range" Deviation types

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

1 REPLY 1


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.

Top Tags