Perspective dynamic props path

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

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

I thought this would work but it doesn’t.

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(“[0].”+ SomeVariable) ?

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

someVariable = 'OrderId'

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

If someVariable represents a property name, you want to use python’s built-in getattr() function to perform the retrieval. Something like this:

getattr(self.getSibling(“Table”)[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.

1 Like

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”)[0][someVariable]” it didn’t work.


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

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 @PGriffith.