Skip to main content
16-Pearl
August 8, 2022
Solved

Parameters of QueryNamedPropertyHistory.

  • August 8, 2022
  • 1 reply
  • 1084 views

Hello everyone,

 

I am trying to make use of the QueryNamedPropertyHistory service.  I need to pass the property names. 

This is what I have:

 

let result = me.QueryNamedPropertyHistory({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER {"defaultValue":500} */,
endDate: undefined /* DATETIME */,
propertyNames: {"myDataShape": "prop1, prop2, prop3"}/* STRING /* INFOTABLE {"dataShape":"EntityList"} */,
query: undefined /* QUERY */,
startDate: undefined /* DATETIME */
});

 

 

However, I get the following error: Unable To Convert From org.json.JSONObject to INFOTABLE - See Script Error Log for more details.

 

My take is that I am passing the property names incorrectly. Do you perhaps have any suggestions for me?

Much appreciated. 

Thank you 🙂

Best answer by PaiChung

What is your actual code right now?

Property names is an infotable with the datashape of EntityList, you can create an infotable using datashape and create infotable row from datashape and then use addrow to get a proper list for the query. 

1 reply

PaiChung22-Sapphire IAnswer
22-Sapphire I
August 8, 2022

What is your actual code right now?

Property names is an infotable with the datashape of EntityList, you can create an infotable using datashape and create infotable row from datashape and then use addrow to get a proper list for the query. 

Janicen16-PearlAuthor
16-Pearl
August 10, 2022

Thank you @PaiChung  this worked.

 

Below is my actual code:

 

let params = {
infoTableName: "HistoryTable" /* STRING {"defaultValue":"InfoTable"} */,
dataShapeName: "propDS" /* DATASHAPENAME */
};
var ValuesTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);


var currentThing = ThingInputName;

// result: INFOTABLE dataShape: "PropertyDefinition"
let x = Things[currentThing].GetNumericLoggedProperties();

for (let i =0; i<x.length; i++){
ValuesTable .AddRow({'name': x[i].name});
}
//// result: INFOTABLE dataShape: ""
//let history= Things[currentThing].QueryNamedPropertyHistory({
// oldestFirst: undefined /* BOOLEAN */,
// maxItems: undefined /* NUMBER {"defaultValue":500} */,
// endDate: undefined /* DATETIME */,
// propertyNames: ValuesTable /* INFOTABLE {"dataShape":"EntityList"} */,
// query: undefined /* QUERY */,
// startDate: undefined /* DATETIME */
//});
//let result = history;