Skip to main content
15-Moonstone
January 2, 2018
Solved

How to get the property value where Thing name and property name is dynamic

  • January 2, 2018
  • 4 replies
  • 6651 views

Hello Team,

I have a scenario where i need to get the property value where Thing name and property name is dynamic.

var dynThingName = "Thing1";

var dynPropName = "prop1";

result = Things[dynThingName ].dynPropName ;


Failed to get the value, dynPropName is not getting value bcoz it searches for dynPropName which is not defined.

I have used GetNamedPropertyValues but for a single property value i need to create a infotable as input parameter.


Any other ways to get the value in a simple way.


Thanks

Sunay

Best answer by CarlesColl

Should be with [] --> Things[dynThingName][dynPropName]

4 replies

22-Sapphire I
January 2, 2018

You should be able to get it with

Things[dynThingName](dynThingProperty) or perhaps both are ( )

sbt15-MoonstoneAuthor
15-Moonstone
January 3, 2018

Hello Chung,

Tried putting ( ) across the dynamic property, but i am still get the error.

Thanks

Sunay

1-Visitor
January 3, 2018

Should be with [] --> Things[dynThingName][dynPropName]

sbt15-MoonstoneAuthor
15-Moonstone
January 3, 2018

Thanks Carles. It works