How to Reference Form Functions from Button Click Handler

I'm trying to call a function in my form's main code from within the click handler for a Button control. I am getting a "function not defined" reference error.

I feel like I had seen the solution for this in the forums once before, but I could not find it with a search, and there does not seem to be anything in the documentation.

Is there a simple way to reference functions in the form's main script from within the button's code-behind?

Thank you.

Hello @chs-web,

You need to define function globally in the main script like so:

window.alertBox = function(e) {
        alert('Hello!');
    }

Thus, you can call a function from the button's click event:
image

Yes of course, thank you.

1 Like