Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

   support@gingerhelp.com

E P I C O R C U STO M I Z AT I O N S :
A D D I N G YO U R OW N
AC T I O N S M E N U E N T R I E S
ADAM ELLIS · OCTOBER 18, 2019

As developers of Epicor customizations, our aim should typically be to try


to make our work look and feel like standard Epicor screens. Take, for
example, an aspect of a customization I was doing for a customer where
they had asked for a tool to copy price lists easily. While I could have
certainly placed a button on the screen somewhere to fire off that logic,
the “Epicor way” would be to place this functionality within an Actions
menu like so:

L E T ' S C H AT A B O U T YO U R E P I C O R C U STO M I Z AT I O N
R E Q U I R E M E N TS

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 1/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

So how do we go about doing this? You want to start by adding the


following block of code within InitializeCustomCode:

string newButtonName = "CopyPriceList";


string newButtonCaption = "Copy Price List";
int newButtonIndex = 2;

ButtonTool btnCopyPriceList = new ButtonTool(newButtonName


btnCopyPriceList.SharedProps.Caption = newButtonCaption;
if (!baseToolbarsManager.Tools.Exists(newButtonName)) {
baseToolbarsManager.Tools.Add(btnCopyPriceList);
PopupMenuTool actionsMenu = (PopupMenuTool)baseToolbar
actionsMenu.Tools.InsertTool(newButtonIndex, newButton
}

The first 3 lines are all you need to edit should you reuse this snippet in
your project. In the first line, we are giving this new menu entry a name -
in our case “CopyPriceList.” Typical object naming rules here, no spaces
or special characters, and make it something logical. Next, we define the
label this menu entry shows up with, in our case, “Copy Price List.” Lastly,
we have the new menu index - for this one, you want to look at the
existing menu and determine the index of where you want your new
menu entry to show up (starting your counting at 0). So for myself, I
wanted my new entry to come right after ‘Export,’ which is at index 1,
hence my selection of 2 for the new index. The menu entry currently at
index 2 (Attachments) is bumped to position 3 when our new menu entry
is added.

The remaining lines of code are going to be boilerplate, but you can see
what they do - a new ButtonTool object is created, a caption is applied to

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 2/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

it, a test runs to see if the button already exists and, if not, it is added and
assigned to the Actions menu.

So now we have a button that doesn’t do anything. To wire it up you will


want to add a form event for ToolClick using the wizard:

And then within that generated code block test for the condition that our
menu entry was clicked:

private void baseToolbarsManager_ToolClick(object sender,


switch (args.Tool.Key)
{
case "CopyPriceList":
MessageBox.Show("Your code goes here!");
break;
https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 3/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

default:
break;
}
}

If you haven’t used this ToolClick form event handler before, note that ALL
button/menu click events show up in here, and that is why we do a test
on args.Tool.Key to make sure we are only looking for a specific button or
menu item.

So one last bit to button this up - in many Epicor screens, you would see a
menu action like this only be enabled if it were relevant. So in the
example case here, I would only want to see the copy price list option be
made available if I had a price list loaded up on the screen. The ‘Enabled’
shared property on ButtonTool can help us to accomplish this. To set this
up first you will need to define that ButtonTool at the script level as
opposed to within InitializeCustomCode:

public partial class Script


{
ButtonTool btnCopyPriceList;
...

Now we make only a slight tweak to our InitializeCustomCode snippet


such that we are not initializing the ButtonTool (the only change here is on
the line where we define the new ButtonTool):

string newButtonName = "CopyPriceList";


string newButtonCaption = "Copy Price List";

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 4/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

int newButtonIndex = 2;

btnCopyPriceList = new ButtonTool(newButtonName);


btnCopyPriceList.SharedProps.Caption = newButtonCaption;
if (!baseToolbarsManager.Tools.Exists(newButtonName)) {
baseToolbarsManager.Tools.Add(btnCopyPriceList);
PopupMenuTool actionsMenu = (PopupMenuTool)baseToolbar
actionsMenu.Tools.InsertTool(newButtonIndex, newButton
}

Now add an EpiViewNotification for the data that will drive whether this
menu item should be enabled or disabled:

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 5/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

And then within that code stub Epicor puts in for us use that ‘Enabled’
shared property as you see fit - for me I am just enabling it so long as
there is a PriceLst row present:

private void edvPriceLst_EpiViewNotification(EpiDataView v


if (args.Row > -1) {
btnCopyPriceList.SharedProps.Enabled = true;
} else {
btnCopyPriceList.SharedProps.Enabled = false;
}
}

That’s it - hopefully this helps somebody out there!

LET'S CHAT ABOUT YOUR EPICOR


CUSTOMIZATION REQUIREMENTS

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 6/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

AUTHOR: Adam Ellis


Adam Ellis is the owner of
GingerHelp. Adam is a lifelong
entrepreneur and has extensive ERP
and mobile software knowledge
through his consulting and
management experience. He has a
passion for exploring innovative ideas
and how they can change the status
quo. Connect with Adam on LinkedIn
to learn more about his involvement
in the ERP space.

FACEBOOK TWI TTER PINTEREST 0 LIKES

COMMENTS (3) Newest First

Preview POST COMMENT…

Ahmed 2 months ago · 0 Likes

using Infragistics.Win.UltraWinToolbars;

Peeter Salu 7 months ago · 0 Likes

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 7/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

It gives me an error:
The type or namespace name 'ButtonTool' could not be found (are you missing a
using directive or an assembly reference?)

What reference I could use ?


using System.Windows.Forms; didn't help

Mark Miller A year ago · 0 Likes

Thanks Adam, as always, great stuff

PREVIOUS

CREATING A CUSTOM SCHEDULED TASK WITHIN EPICOR


EPICOR ERP, EPICOR CUSTOMIZATION, EPICOR BPM

NEXT

LAUNCHING AN EPICOR 10 SCREEN WITH A SPECIFIC


CUSTOMIZATION FROM CODE
EPICOR ERP, EPICOR CUSTOMIZATION

LET’S CHAT!

CONTACT US

SERVICES PRODUCTS

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 8/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

GINGERHELP, Epicor ERP Epicor ERP KNOWLEDGE


Consulting Extensions
LLC BASE
P21 ERP Infor
8685 Fox Consulting VISUAL ERP Epicor ERP Articles
Lake Road Infor Extensions Infor VISUAL Articles
Sterling, OH VISUAL ERP Dynamics 365
44276 USA Consulting Articles
Dynamics Crystal Reports
 365 Articles
 support@gingerhelp.com Consulting SSRS Articles
SSRS Bezlio for Mobile
Developer ERP Articles
Services
Crystal
Reports
Consulting

GingerHelp is an
independent consulting
practice with no direct
© 2019 - 2023 GingerHelp,
affiliation with Epicor® or
LLC
Infor®.

Terms & Conditions |


Epicor®, Vantage®, and Privacy Policy
Prophet 21™ are registered
trademarks of Epicor
Software Corporation®.
Infor® and VIUSAL® are
registered trademarks of
Infor®.
Crystal Reports® is a
https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 9/10
4/25/23, 12:04 PM Epicor Customizations: Add Action Menu Entries — GingerHelp

registered trademark of SAP


AG.

https://www.gingerhelp.com/knowledgebase-epicor-erp/adding-your-own-actions-menu-entries 10/10

You might also like