Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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
Solved! Go to Solution.
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.
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.
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;