Clicking a button programmatically

I’m trying to work around the fact that there is no way to define reusable functions in the context of a page. I don’t want to pollute the global functions with functions which only make sense on one page. This often led me to writing redundant code within one page. An example is, that I want to execute the same code when clicking a button or when clicking an image/icon. Generally, anywhere in my page code I might want to execute code which is defined within the click-event of some button on the page. This way, I might even define invisible buttons with click-events which serve as carrier of the reusable code pieces.

The solution I’ve found is very simple. I want to share it here, but also want to ask BE-support to validate whether this is a feasible and robust approach.

Let’s say you have a button on a page with assigned Id closeDocButton2. If you want to “click” on that button programmatically, add the following block:

image

The custom code looks as follows:

Happy trying … :grinning:
Regards,

3 Likes

Hello @Klaas_Klever,

thanks for sharing this!
I do not see any problems with such approach.

Regards,
Stanislaw