2 Replies Latest reply on Jan 18, 2018 4:54 PM by dsawyer RSS
    dsawyer Explorer

    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[x];
        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 + ") ");
      • Re: create infotable from loop
        Adam Macierzyński Apprentice

        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++)


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


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