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
adaniell
(Adam)
January 25, 2021, 1:46pm
2
PerformClick
SubmitButton.PerformClick();
3 Likes
utaylor
(Utah Taylor)
January 25, 2021, 1:56pm
3
Do you have to have an event handler as well or does it invoke the native click event?
adaniell
(Adam)
January 25, 2021, 1:58pm
4
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
utaylor
(Utah Taylor)
January 25, 2021, 2:03pm
5
Right right, I just tried it out on ABC code and it works great.
Banderson
(Brandon Anderson)
January 25, 2021, 2:08pm
6
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.
adaniell
(Adam)
January 25, 2021, 2:20pm
7
Please share, how do you use the wizard to invoke the click event on native buttons?
Banderson
(Brandon Anderson)
January 25, 2021, 2:21pm
8
You can’t do it with native buttons. You have to make your own.
adaniell
(Adam)
January 25, 2021, 2:22pm
9
OP was asking about the native Submit button.
But I am curious how to invoke events with custom buttons, using the wizard?
adaniell
(Adam)
January 25, 2021, 2:55pm
11
That explains how to subscribe to an event, we were discussing invoking events.
Is that possible with the wizard?
Banderson
(Brandon Anderson)
January 25, 2021, 2:57pm
12
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.
adaniell
(Adam)
January 25, 2021, 3:01pm
13
OP’s question was about programmatically invoking the button click, not handling the event.
Banderson
(Brandon Anderson)
January 25, 2021, 3:13pm
14
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