Custom Method from expression

I have a Custom Method on the Root Container called “GetText” that does a calculation that I would like to display as text in a label. When I have a project script that I want to run from a label express i use the runScript function with something like this:
runScript(“project.GetText()”)
but how do i call a script that is a Custom Method?

I have tried the following but none of them work:
runScript(“GetText()”)
runScript(“self.GetText()”)
runScript(“parent.GetText()”)

Any help appreciated.

You can’t. :frowning: The runScript() expression function only exposes the system., project., and shared.* namespaces to the given script expression.

Passing a ‘this’ object sounds like a useful feature. Maybe you should put in a feature request?

Thanks for the info Phil.
I’ll try a different tack.

Note to newcomers: as of v7.8, runScript supports the self keyword in component bindings.

1 Like

Hello Phil, so is this now possible?

Sort of. The custom methods of the component where the binding is placed are available to runScript(). They wouldn’t be available to bindings on another component. To have complete flexibility on what you can call, you still need my objectScript function.