Is there a "this" type reference in the expression language?

I have an expression binding on the border property of a container. I would like to use this container like a template without actually being a template if that makes sense, where there will be multiple containers on a single window. Within my expression I need the “name” property of the container. If there are multiple containers on a screen and depending on if things are grouped together or not, trying to get the name property of the container within the expression becomes a bit of a pain. Is there any way to reference the object, ie the container, that the binding is tied to? In java it might look something like “this.name” as a reference to the name.

There is not a way to do this within the expression language (might be good for ideas.inductiveautomation.com).

However, there is a workaround. I would caution that this can cause unnecessary CPU load, and so I would definitely recommend simply using a template. However, in an expression binding using runScript, self is available in the namespace. So: runScript("self.name") will return the name of the component that fired the expression.

2 Likes

Similarly, you can use the binding.target local variable in objectScript() expressions. So: objectScript("binding.target.name") does the same as Paul’s example. The advantage of objectScript() is its ability to reference binding.target while computing a python one-liner that includes passed parameters (in args).

1 Like