Easier way on adding Action Menu in Existing Graph

Hi Guys, to help you with coding or adding a Menu Action to an existing screen.

Level: Basic

Example Scenarios:

  • Grouping Customized Reports 
  • Organized Action Buttons Folder instead of displaying all buttons in toolbar

First we need to define our Action Buttons

  • Folder Action
    • Action1
    • Action2

Then we override the screen’s Initialize() or Initialization Process

Using public override void Initialize() then we add the Actions to the Action Folder with  this.ButtonFolder.AddMenuAction(ButtonItem1);

Furthermore, please include  MenuAutoOpen = true to make the button not clickable as button and will act as a dropdown button.

Please refer to the code below:

namespace PX.Objects.AP
{
  public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
  {
    public override void Initialize()
    {
        base.Initialize();
        this.ButtonFolder.AddMenuAction(ButtonItem1);
        this.ButtonFolder.AddMenuAction(ButtonItem2);
    }

    public PXAction<PX.Objects.AP.APInvoice> ButtonItem1;
    [PXButton(CommitChanges = true)]
    [PXUIField(DisplayName = "ActionItem1")]
    protected void buttonItem1()
    {
        //code logic here
    }

    public PXAction<PX.Objects.AP.APInvoice> ButtonItem2;
    [PXButton(CommitChanges = true)]
    [PXUIField(DisplayName = "ActionItem2")]
    protected void buttonItem2()
    {
       //code logic here
    }
	
    public PXAction<PX.Objects.AP.APInvoice> ButtonFolder;
    [PXButton(SpecialType = PXSpecialButtonType.Report, MenuAutoOpen =true)]
    [PXUIField(DisplayName = "ActionFolder")]
    protected void buttonFolder()
    {
       //code logic here
    }

Just publish the Customization Project, and it will apply accordingly.

That’s it, have a nice development.

Leave a Reply

Your email address will not be published. Required fields are marked *