3 Replies Latest reply on Oct 26, 2017 10:28 AM by carlesc RSS
    ddaud Explorer

    Input date to refresh infotable

    I have inserted two input date: startDate and endDate.

     

    I have inserted this JS code in my service:

    var params = {
        infoTableName : "InfoTable",
        dataShapeName : "TFPeopledata",
        startDate: startDate,
        endDate: endDate,
        maxItems: maxValues
    };
    
    var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
    
    for each(var row in res.rows){
                var newEntry = new Object();
                newEntry.People_in_region = row.People_in_region;
                newEntry.date_trunc = dateAddHours(row.date_trunc, -2); // DATETIME
                result.AddRow(newEntry);
    }
    

     

    The prob is don''t refresh with date selected.

    Screenshot-2017-10-26 ThingWorx Composer(1).png

      • Re: Input date to refresh infotable
        carlesc Heavyweight Champ

        I don't see the query, but anyway, your code duplicates entries ( as you are iterating over result collection variable and in the loop you are adding to the same result collection variable ). This is Javascript code not Java code I'm right?

          • Re: Input date to refresh infotable
            ddaud Explorer

            I have used a ValueStream for data storage

             

            var res = Resources["CSVParserFunctions"].ReadCSVFile(params);
            
            var maxValues = 100;
            var oldFirst = false;
            if(startDate != undefined){
                maxValues = 5000;
            //    oldFirst = true;
            }
            
            var params = {
                oldestFirst: false /* BOOLEAN */,
                endDate: endDate /* DATETIME */,
                maxItems: maxValues /* NUMBER */,
                startDate: startDate /* DATETIME */
            };
            var history = me.QueryPropertyHistory(params);
            
            var result = history;
            var params = {
                infoTableName : "InfoTable",
                dataShapeName : "TFPeopledata",
                startDate: startDate,
                endDate: endDate,
                maxItems: maxValues
            };
            var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
            
            for each(var row in res.rows){
                        var newEntry = new Object();
                        newEntry.People_in_region = row.People_in_region;
                        newEntry.date_trunc = dateAddHours(row.date_trunc, -2); // DATETIME
                        result.AddRow(newEntry);
            }
            

            I got this as a result:
            Results

            timestamp

             

            I think the prob with the data stream.