Skip to main content

Hello!

Mi instance is 22R2 and until now, conditionally enabling/disabling custom actions had been pretty easy.

Usually I just use the SetEnable Method in a RowSelected event… Like this one here that I’m trying to use for a custom action in the SOInvoice screen:

 protected void _(Events.RowSelected<SOInvoice> e)
{
SOInvoice row = e.Row;
if (row == null) return;
itemSearch.SetEnabled(Base.Document.Current.CustomerID == null ? false : true);

}

The problem that I’m facing right now is that visually, the button remains “Enabled” at all times, while logically the button is disable until the user enters the customer:

When the user clicks on the button without entering a Custmer. The condition works and the system display the alert: 

But the button remains visually enabled and my eye is twitching becouse of this!

In the aspx I placed the button inside the actionbar like I have done with many other customizations:

<ActionBar>
<CustomItems>
<px:PXToolBarButton Text="Search Items">
<AutoCallBack Target="ds" Command="ItemSearch">
<Behavior CommitChanges="True" PostData="Page" /></AutoCallBack></px:PXToolBarButton>
<px:PXToolBarButton Text="Add Order" Key="cmdShipmentList">
<AutoCallBack Command="SelectShipment" Target="ds">
<Behavior PostData="Page" CommitChanges="True" ></Behavior>
</AutoCallBack>
</px:PXToolBarButton>

I hope somebody could give light on this little frustrating issue.

Thanks!

Hi @albertobello83  Basically enabling/disabling the grid action based on the below two properties for the PXToolBarButton control.

  1. StateColumn
  2. DependOnGrid

Please find the article link below for your reference.

https://blog.zaletskyy.com/post/2015/01/27/post78

 


Hi @albertobello83 ,


I have found similar article for your question, could you please go through this.

Corrcetly disabling a custom action button | Community (acumatica.com).
 

Hope, It helps!
 

Regards,

Sweta


Thanks for the links.  I was able to get the button to show as disabled on the Sales Quotes screen but not the Opportunities screen by adding the StateField.  Exact same c# code, exact same ASPX code on both screens.  It doesn’t work on the Opportunities screen.

This still does not allow me to hide the button.

The button was a “professional” add on to make the screen better.  Since I cannot hide a custom button, I’m just removing it.  I’ve spent enough time on it.

I appreciate the effort from you both.  


Reply