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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Getting the value from QueryNamedPropertyHistory

jensc
17-Peridot

Getting the value from QueryNamedPropertyHistory

Hello Community,

 

I just got stuck on an issue and was hoping that perhaps someone here could help me.

I am using the QueryNamedPropertyHistory function for a property.

 

Getting this data, I want to loop it over and use each value for something.

 

Now, the issue I am facing is that the infotable data shape being used for the QueryNamedPropertyHistory is "dynamic".

 

It has the "timestamp" column and then the value column with is named after the property.

This makes it so I cant just do:

 

const propertyValues = Things[EntityName].QueryNamedPropertyHistory({
    ***params***
  });

  propertyValues.rows.toArray().forEach((element) => {
   let propertyValue = element.value;
   let propertyTimestamp = element.timestamp;
  });

 

As the "value" column changes name based on the property name.

 

I know you can do something like: 

Things[DynamicThing][DynamicProperty]

 

But is something similar possible in my use case?

Or how would you go about it?

 

Thanks,

Jens C.

ACCEPTED SOLUTION

Accepted Solutions
jensc
17-Peridot
(To:jensc)

Hello Community,

 

I got some help from a colleague and they said it is possible to do:

element[PropertyName]

To get the value of the JSON key.

I should've known how to use this square bracket notation!

 

Thanks,

Jens C.

View solution in original post

1 REPLY 1
jensc
17-Peridot
(To:jensc)

Hello Community,

 

I got some help from a colleague and they said it is possible to do:

element[PropertyName]

To get the value of the JSON key.

I should've known how to use this square bracket notation!

 

Thanks,

Jens C.

Announcements


Top Tags