# Button Action From Code

**URL:** <https://www.epiusers.help/t/button-action-from-code/74824>\
**Category:** Epicor ERP 10\
**Tags:** customization, e10\
**Created:** [January 25, 2021, 1:11pm UTC](https://www.epiusers.help/t/button-action-from-code/74824 "2021-01-25T13:11:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdewitt6029](https://www.epiusers.help/user_avatar/www.epiusers.help/jdewitt6029/32/10215_2.png) [@jdewitt6029](https://www.epiusers.help/u/jdewitt6029)\
**Post date:** [January 25, 2021, 1:11pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/1 "2021-01-25T13:11:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![adaniell](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@adaniell](https://www.epiusers.help/u/adaniell)\
**Post date:** [January 25, 2021, 1:46pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/2 "2021-01-25T13:46:35Z")

</div>

PerformClick

```auto
SubmitButton.PerformClick();
```

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [January 25, 2021, 1:56pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/3 "2021-01-25T13:56:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adaniell](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@adaniell](https://www.epiusers.help/u/adaniell)\
**Post date:** [January 25, 2021, 1:58pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/4 "2021-01-25T13:58:34Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [January 25, 2021, 2:03pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/5 "2021-01-25T14:03:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [January 25, 2021, 2:08pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/6 "2021-01-25T14:08:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adaniell](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@adaniell](https://www.epiusers.help/u/adaniell)\
**Post date:** [January 25, 2021, 2:20pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/7 "2021-01-25T14:20:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [January 25, 2021, 2:21pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/8 "2021-01-25T14:21:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adaniell](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@adaniell](https://www.epiusers.help/u/adaniell)\
**Post date:** [January 25, 2021, 2:22pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/9 "2021-01-25T14:22:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [January 25, 2021, 2:51pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/10 "2021-01-25T14:51:35Z")

</div>

> [@Epi button to refresh embedded BAQ](https://www.epiusers.help/t/epi-button-to-refresh-embedded-baq/70601/2):
>
> Place an epibutton on the form. Then use the Event Wizards to the button click event like so… [image] In the event handling code section, insert the code Jose provided in the above post. (Make sure you change the baqDataView to yours). Also make sure you add the “using” statement to the top.

---

<div class="post-metadata">

**Author:** ![adaniell](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@adaniell](https://www.epiusers.help/u/adaniell)\
**Post date:** [January 25, 2021, 2:55pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/11 "2021-01-25T14:55:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [January 25, 2021, 2:57pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/12 "2021-01-25T14:57:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adaniell](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@adaniell](https://www.epiusers.help/u/adaniell)\
**Post date:** [January 25, 2021, 3:01pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/13 "2021-01-25T15:01:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [January 25, 2021, 3:13pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/14 "2021-01-25T15:13:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jdewitt6029](https://www.epiusers.help/user_avatar/www.epiusers.help/jdewitt6029/32/10215_2.png) [@jdewitt6029](https://www.epiusers.help/u/jdewitt6029)\
**Post date:** [January 25, 2021, 5:28pm UTC](https://www.epiusers.help/t/button-action-from-code/74824/15 "2021-01-25T17:28:42Z")

</div>

Perfect. That is what i needed.
