Hi guys,
I am trying to generate a time series chart with a certain property from all the things of that template. I am trying to write a service in a thing that will get the data required for the graph. The service I have however returns all the properties and does not filter on the property infotable as expected.
Can anyone please assist with how I can achieve this? My service code is below.
//GetDataTrend
// today date
today = new Date();
// if no date specified
if (!StartDate){
StartDate = dateAddHours(today, -24);
}
if (!EndDate){
EndDate = today;
}
// create infotable to collect data
var params = {
infoTableName : "InfoTable",
dataShapeName : "EntityList"
};
// CreateInfoTableFromDataShape
var propInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
// EntityList entry object
var MotorSpeed = new Object();
MotorSpeed.name = "MotorSpeed"; // STRING [Primary Key]
MotorSpeed.description = undefined; // STRING
propInfoTable.AddRow(MotorSpeed);
// result: INFOTABLE dataShape: ""
var result = ThingTemplates["FELE.Dewater.BoreholePump.TT"].QueryImplementingThingsWithNamedPropertyHistory({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER */,
endDate: EndDate /* DATETIME */,
propertyNames: propInfoTable /* INFOTABLE */,
nameMask: undefined /* STRING */,
query: undefined /* QUERY */,
maxDataItems: undefined /* NUMBER */,
dataQuery: undefined /* QUERY */,
startDate: StartDate /* DATETIME */,
tags: undefined /* TAGS */
});
I used to do this with the GetPropertyDefinitions service and then selected row.
It uses the following DataShape: PropertyDefinition ...
Still 'name' though but try with the CreateInfoTableEntryFromDataShape together with your CreateInfoTable