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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Creating Email alert based on % of target value

Darryl
4-Participant

Creating Email alert based on % of target value

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

1 REPLY 1
mlähde
3-Visitor
(To: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

Top Tags