# Perspective dynamic props path

**URL:** <https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153>\
**Category:** Ignition Early Access\
**Created:** [February 12, 2020, 12:31am UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153 "2020-02-12T00:31:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsteward](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@jsteward](https://forum.inductiveautomation.com/u/jsteward)\
**Post date:** [February 12, 2020, 12:31am UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153/1 "2020-02-12T00:31:04Z")

</div>

I know this must be easy to do, but I just can’t find or figure out the syntax. I’m looking for an equivalent function or method in perspective to build a dynamic props path so that I can get the value through scripting.

This is the hard coded props path I want  
self.getSibling(“Table”).props.selection.data[0].OrderID

I want to be able to use a variable in the path.

I thought this would work but it doesn’t.  
self.getSibling(“Table”).props.selection.data[0][SomeVariable]

Is there a way to construct the path as a string and then get the value of the property such as  
self.getSibling(“Table”).getValue(“props.selection.data[0].”+ SomeVariable) ?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 12, 2020, 3:17pm UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153/2 "2020-02-12T15:17:33Z")

</div>

It depends on the structure of the `data` object of the table, but something like the following should work for you:

```auto
someVariable = 'OrderId'
self.getSibling("Table").props.data[0][someVariable]

```

You just need to make sure the table’s data structure doesn’t change, and that the key you supply is a String.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 12, 2020, 4:06pm UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153/3 "2020-02-12T16:06:46Z")

</div>

If `someVariable` represents a property name, you want to use python’s built-in [getattr()](https://docs.python.org/2.7/library/functions.html#getattr) function to perform the retrieval. Something like this:

```auto
getattr(self.getSibling(“Table”).props.selection.data[0], SomeVariable)

```

In python, bracket syntax only works with subscript lookup in lists/arrays, or key lookup in dictionaries. The dot operator only accepts a fixed string in the code for the lookup of properties.

---

<div class="post-metadata">

**Author:** ![jsteward](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@jsteward](https://forum.inductiveautomation.com/u/jsteward)\
**Post date:** [February 12, 2020, 7:34pm UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153/4 "2020-02-12T19:34:52Z")

</div>

I knew there had to be a simple way to do that. Exactly what I was looking for.

Both methods worked by the way. Not sure why the first time I tried  
“self.getSibling(“Table”).props.data[0][someVariable]” it didn’t work.

Thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 12, 2020, 8:45pm UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153/5 "2020-02-12T20:45:10Z")

</div>

> [@jsteward](#):
>
> Both methods worked by the way.

Bracket syntax for a property must be a Perspective data type enhancement. Nice.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 12, 2020, 8:50pm UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153/6 "2020-02-12T20:50:46Z")

</div>

One of the Devs recently modified the wrapper objects to behave more like Python datatypes, so you access them (for the most part) as you would a python datatype. This prevents users from encountering instances where they get an Array (or ArrayList?) object but can’t iterate through it with a python for loop because it isn’t a list, or instances where an ObjectWrapper had to be used as a Java object. You can thank @paul-griffith.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 8, 2023, 3:57pm UTC](https://forum.inductiveautomation.com/t/perspective-dynamic-props-path/32153/7 "2023-12-08T15:57:45Z")

</div>

Split this topic on December 8, 2023, 3:57pm UTC

2 posts were split to a new topic: [Dynamic Row/Column table creation?](https://forum.inductiveautomation.com/t/dynamic-row-column-table-creation/82902)
