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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Parameters of QueryNamedPropertyHistory.

Janicen
16-Pearl

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

ACCEPTED SOLUTION

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

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:Janicen)

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;

Announcements


Top Tags