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

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

create infotable from loop

Darryl
4-Participant

create infotable from loop

Hi All

Please could I get some advise (probably fundamentals).

I have the following code that I would like to display and send an email of an infotable as the result. How do I go about this?

var CurrentTime = new Date();

var sourceData = ThingTemplates["MeterTemplate"].GetImplementingThingsWithData();

var tableLength = sourceData.rows.length;

for (var x = 0; x < tableLength - 1; x++) {

    var currentRow = sourceData.rows;

    var sendfrom = "";

  

 

  

  

    var source = currentRow.name;

        if(CurrentTime.getTime() - Things[source].lastMeasureTime > 86400000) {

       logger.warn("Alert: (" + Things[source].name + ") hasnt recorded data since (" + Things[source].lastMeasureTime + ") ");

       }

}

2 REPLIES 2
A_Macierzynski
14-Alexandrite
(To:Darryl)

Hi Darryl,

Can you tell us where the problem is? Are you receiving any errors? If so, where exactly?

Btw. I noticed standard looping issue in your code. It should look like this:

for(var x=0; x < tableLength; x++)

or

for(var x=0; x <= tableLength -1; x++)

Otherwise you will lose your last record, while iterating through infotable.

Regards,

Adam

Darryl
4-Participant
(To:A_Macierzynski)

Hi Adam

My problem is that I am not sure how to output the iteration into an infotable, and then email that infotable.

I get the results I am looking for posted to my log, but want a displayed infotable as well as an email.

Any help?

Top Tags