Button Action From Code

This is out of my ignorance but how do I trigger a button from code. For example, on Kanban Receipts form, I am working on a customization where I want to submit the form just as if the user clicked the Submit button (there are two buttons on that form). I am just missing the syntax I believe.

Can someone help me out?

1 Like

PerformClick

SubmitButton.PerformClick();
3 Likes

Do you have to have an event handler as well or does it invoke the native click event?

That just invokes the click event.
You could handle the event as well but it’s not needed.
You do(of course) need a handle to the button and since this is a native button, use

EpiButton SubmitButton = (EpiButton)csm.GetNativeControlReference("Your button's EPI GUID here");
2 Likes

Right right, I just tried it out on ABC code and it works great.

Use the wizard to make your click event. There really isn’t a reason not to. Let us know if you can’t find it.

Please share, how do you use the wizard to invoke the click event on native buttons?

You can’t do it with native buttons. You have to make your own.

OP was asking about the native Submit button.
But I am curious how to invoke events with custom buttons, using the wizard?

That explains how to subscribe to an event, we were discussing invoking events.
Is that possible with the wizard?

You are making a click event. When you use the wizard, it makes and event that fires when you click the button.

I don’t understand what you are asking.

OP’s question was about programmatically invoking the button click, not handling the event.

Ah, now I get it. I misunderstood the question. No, you’ll just have to use the code posted above.

Perfect. That is what i needed.

1 Like