Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi All
I am trying to create an email alert that is based on a user defined % of a target value from a service calculation:
var CurrentTime = new Date();
var Midnight = new Date();
Midnight.setHours(0,0,0,1);
var params = {
oldestFirst: true /* BOOLEAN */,
maxItems: undefined /* NUMBER */,
sourceTags: undefined /* TAGS */,
endDate: CurrentTime /* DATETIME */,
query: undefined /* QUERY */,
source: source /* STRING */,
startDate: Midnight /* DATETIME */,
tags: undefined /* TAGS */
};
// result: INFOTABLE
var result = Things["ApexReadingsStream"].QueryStreamEntriesWithData(params);
var newField = new Object();
newField.name = "Difference";
newField.baseType = 'NUMBER';
result.AddField(newField);
var tableLength = result.rows.length;
for (var x = 0; x < tableLength - 1; x++) {
var newerRow = result.rows[x +1]
var olderRow = result.rows
; //row.Difference = row.Value-result.rows[x-1].Value;
newerRow.Difference = (newerRow.Value-olderRow.Value) * 1000 ;
}
I am struggling to understand the concept of how to achieve this in thingworx?
Any suggestions from anyone...
Thanks
Darryl
Hello, Darryl. Did you import the Mail Extension yet? ThingWorx IoT Marketplace
If not, do so, then create your own mail server thing (which implements the MailServer thing template), configure the mail server thing and then call the SendMessage service from within your service where you do the calculations.
For details on how to configure the server, check the extension user guide from the aforementioned marketplace link. Also, here's a little document about using a Gmail account with the Mail Extension: Google e-mail and mail extension: set up and troubleshooting