ThingWorx Model Definition in Composer > Modeling > Things > Alerts > AddOrUpdateAlert Service Attributes
AddOrUpdateAlert Service Attributes
The attributes parameter on the AddOrUpdateAlert service is an infotable with no defined Data Shape. Because of this, the Test button for the service does not allow you to define the infotable for this parameter. The infotable expected by this service varies depending on the type of alert and the base type of the property configured for the alert. In order to call the AddOrUpdateAlert service, the infotable must be dynamically configured as described in the tables below.
Parameter Definitions
Parameter
Definition
value
Specifies the target value, used in EqualTo / NotEqualTo or DeviationAbove / DeviationBelow alerts.
limit
Specifies the threshold value when used in Above / Below alerts.
Specifies the minimum amount that a value must deviate from the target to trigger DeviationAbove / DeviationBelow alerts.
limitInclusive
Includes values equal to the limit value in the comparison.
minimum
The lowest target value for InRange / OutOfRange alerts.
minimumInclusive
Includes values equal to the minimum in the comparison.
maximum
The highest target value for InRange / OutOfRange alerts.
maximumInclusive
Includes the values equal to the maximum in the comparison.
BOOLEAN
Alert Types
Expected Attributes (Infotable's Data Shape)
EqualTo / NotEqualTo
value: BOOLEAN
DATETIME
Alert Types
Expected Attributes (Infotable's Data Shape)
Above / Below
limit: DATETIME
limitInclusive: BOOLEAN
EqualTo / NotEqualTo
value: DATETIME
InRange / OutOfRange
minimum: DATETIME
minimumInclusive: BOOLEAN
maximum: DATETIME
maximumInclusive: BOOLEAN
DeviationAbove / DeviationBelow
value: DATETIME
limit: NUMBER
limitInclusive: BOOLEAN
units: STRING, one of the following values:
S - seconds
M - minutes
H - Hours
D - Days
N - Months
Y - Years
INFOTABLE
Infotable alerts trigger changes to the row count in the infotable.
Alert Types
Expected Attributes (Infotable's Data Shape)
Above / Below
limit: INTEGER
limitInclusive: BOOLEAN
EqualTo / NotEqualTo
value: INTEGER
INTEGER, NUMBER, and LONG
Alert Types
Expected Attributes (Infotable's Data Shape)
Above / Below
limit: <BASETYPE>
limitInclusive: BOOLEAN
EqualTo / NotEqualTo
value: <BASETYPE>
InRange / OutOfRange
minimum: <BASETYPE>
minimumInclusive: BOOLEAN
maximum: <BASETYPE>
maximumInclusive: BOOLEAN
DeviationAbove / DeviationBelow
value: <BASETYPE>
limit: <BASETYPE>
limitInclusive: BOOLEAN
LOCATION
Alert Types
Expected Attributes (Infotable's Data Shape)
EqualTo / NotEqualTo
value: LOCATION
DeviationAbove / DeviationBelow
value: LOCATION
limit: NUMBER
limitInclusive: BOOLEAN
units: STRING, one of the following values:
M: Miles
K: Kilometers
N: Nautical Miles
STRING
Alert Types
Expected Attributes (Infotable's Data Shape)
EqualTo / NotEqualTo
value: STRING
Example Service Code Calling the AddOrUpdateAlert Service
The following code updates (or creates) an alert on the MyIntProperty integer property named MyAlert. The alert is an Above value alert, and triggers when the MyIntProperty property is set to five or above.
// 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: "MyIntProperty" /* STRING */,
attributes: attrs /* INFOTABLE */,
priority: 1 /* INTEGER */,
persistent: true /* BOOLEAN */,
enabled: true /* BOOLEAN */
};

me.AddOrUpdateAlert(params);
Related Links