How To Enable Disable Menu Item In Acumatica

How to enable disable menu item in Acumatica

Hello everybody,

Today I want to share short glimps how to Enable/Disable menu item. Let's some menu. For example it looks like this:

Suppose, we added menu action Activate in the following way:

public PXAction<EPEmployee> Activate;

[PXButton]
[PXUIField(DisplayName = "Activate")]
protected virtual IEnumerable activate(PXAdapter adapter)
{
   
}
// menu action was added like this:
public override void Initialize()
{
     Actions.AddMenuAction(Activate);
}

Let's say we want to disable menu item Activate. It can be achieved with usage of RowSelected event and SetEnabled function.  In my case I used the following construction:

protected virtual void EPEmployee_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
      Actions.SetEnabled("activate", false);//this code will disable menu item activate
}

Take note, that we declared PXAction, which is repsonsible for menu. Then in action Initialize ( this is code from extension class ) we added menu item. And then we can manipulate with enabling/disabling it through Actions.SetEnabled

2 Comments

  • arsiadi said

    Hi Yuriy, kindly need advice on what event handler of checkbox that must be define to enable/disable action menu. I have this custom "Verify" Action on CRCase screen that need to be enabled once the custom checkbox on FormView is checked.

    Please apologize for asking basic technique as I new to Acumatica framework.

    Thanks...

  • docotor said

    Hi Arsiadi, please describe little bit more your question. You have checkbox. If checkbox is selected, then some menu item should be enabled, and if checkbox is not checked, then menu item should be disabled. If that is the case, then enabling/disabling can be done in RowSelected event.

Add a Comment
Comments are closed