Invoking event scripts from message handler scripts?

I have a perspective page with a button component whose an “on action performed” event script performs various updates to a backend.

The page also has the ​message handler script that populates some dropdown components with data from barcodes. Is it possible for this message handler script to execute the “update” button’s “on action performed” event script?

No, but you shouldn’t have complex scripts in events anyways. Move the code to a project script module function. Then either origin can call the same logic.

3 Likes

Another possibility brought to my attention is to create a custom method, call it execute, that performs the logic of the button’s current event script. The event script can then use self.execute(), and the page’s message handler script can call self.getChild("myUpdateButton").execute() as necessary.

And if you want to call that same code from another view when this one isn't open? If you take @pturmel's suggestion and move the code to a project script that is independent of view, you can call that code from anywhere in the project and not worry about duplicating the code or the component not being available.

Project script is the way to go, IMNSHO

1 Like