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

Input date to refresh infotable

Highlighted
Not applicable

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

3 REPLIES 3

Re: Input date to refresh infotable

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

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.

Re: Input date to refresh infotable

I don't know man, your code doesn't have much sense I'm sorry.