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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Parameters of QueryNamedPropertyHistory.

Tomellache2B
14-Alexandrite

Parameters of QueryNamedPropertyHistory.

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaiChung
22-Sapphire I
(To:Tomellache2B)

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. 

View solution in original post

2 REPLIES 2
PaiChung
22-Sapphire I
(To:Tomellache2B)

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. 

Tomellache2B
14-Alexandrite
(To:PaiChung)

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;

Top Tags