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 called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

create infotable from loop

Darryl
12-Amethyst

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

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

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?

Announcements


Top Tags