Skip to main content
pshashipreetham
18-Opal
18-Opal
May 28, 2021
Solved

Query in Expression

  • May 28, 2021
  • 1 reply
  • 941 views

I am running the following code in the Expression, but there is no output from the Expression. Does QueryNamedPropertyHistory work in Expression?

DataTable = Things["ThingName"].QueryNamedPropertyHistory({
 propertyNames: {
 "rows": [{
 "name": "PropertyName"
 }],
 "dataShape": {
 "fieldDefinitions": {
 "name": {
 "name": "name",
 "aspects": {},
 "description": "",
 "baseType": "STRING",
 "ordinal": 1
 },
 "description": {
 "name": "description",
 "aspects": {},
 "description": "",
 "baseType": "STRING",
 "ordinal": 2
 }
 }
 }
 } /* INFOTABLE */ ,
 maxItems: undefined /* NUMBER */ ,
 query: undefined /* QUERY */ ,
 maxDataItems: 500000 /* NUMBER */ ,
 startDate: startDate /* DATETIME */ ,
 endDate: endDate /* DATETIME */ ,
 oldestFirst: true /* BOOLEAN */ ,
 dataQuery: undefined /* QUERY */
});
if(DataTable.rows.length === 0)
{
	Output = "No Data";
}
else{
	Output = " ";
}

 Thanks,
Shashi.

Best answer by SachinSharma

@pshashipreetham 

 

I don't think the QueryNamedPropertyHistory service will run in the expression function. You can get the length of infotable returned by QueryNamedPropertyHistory in a separate service and pass its output to the expression function. Refer this article explaining all the tasks that can be performed with Expression.

 

1 reply

16-Pearl
May 28, 2021

@pshashipreetham 

 

I don't think the QueryNamedPropertyHistory service will run in the expression function. You can get the length of infotable returned by QueryNamedPropertyHistory in a separate service and pass its output to the expression function. Refer this article explaining all the tasks that can be performed with Expression.