Solved

Set Button conditionally visible

  • 11 December 2022
  • 7 replies
  • 353 views

Userlevel 4
Badge

hello everyone. How can I conditionally set the Pay button to not be visible when  I select a specific payment method.

 

icon

Best answer by aaghaei 11 December 2022, 20:30

View original

7 replies

Userlevel 7
Badge +5

I would expect to do this in the RowUpdated event. You can call the .SetVisible method of the button/action to show/hide it accordingly.

Userlevel 7
Badge +9

@development93
@ddunn 
I believe the suggested even handler for UI controls status management is RowSelected and don’t forget to set CommitChanges = true for the driving field. RowUpdated will be triggered only if a change is made and if a document with the specific type is selected and no change is made the button will be visible. Please note there is a known issue in Acumatica that if a button is added to the user favorite, then always will be visible.

Userlevel 4
Badge

Appreciate for all your responses. is it possible if anyone could share an example?

 

Userlevel 7
Badge +9

@development93 
there are lots of samples on community or stackoverflow but here is one. You can set the true or false value on the fly based on your document type verification you are referring to.

https://stackoverflow.com/questions/44120573/disable-action-buttons-conditionally-aef

Userlevel 7
Badge +5

@aaghaei- you’re right - I just happened to have the training materials open and the example I was looking at was the event to use when you need to update another record when the current record is updated.

I think @development93 wants to look at FieldUpdated as well as RowSelected because the user could change the payment method after selecting the row.

In T210, in Step 3 there is an example around changing the enabled status of a field.

See if that helps you get started. Use the Ctrl+Alt keyboard shortcut to get the details on the Pay button. If it is defined as a PXAction (I would expect so) then you can use graph.action.SetVisible.

 

Userlevel 7
Badge +9

@ddunn

It was a while ago I studied the materials but if I am not mistaken, RowSelected event is triggered multiple times before and after other events including RowUpdated. So if the visibility control developed on RowSelected it should do the work without RowUpdated alteration.

Userlevel 5
Badge +3

Couple of points, if you want to do that via RowSelected:

  1. RowSelected of Main DAC class, not secondary
  2. Make sure that your rowselected doesn’t conflict with Acumatica base code
  3. Acumatica in newer versions adds more and more extensions, so make sure, you analyze base Acumatica extensions
  4. Make sure, that other customizations doesn’t meddle with making button visible.

As alternative, you can also try to use javascript. This link describes usage of js in scope of SignalR, but you can understand abou js as well.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved