Solved

How do I enable a field when clicking on an action?

  • 7 December 2021
  • 7 replies
  • 553 views

Userlevel 1
Badge

The requirement is to enable the Customer Order Nbr when a new action ‘Change Order Nbr’ is selected. I created the below action method. It is executed on clicking the action but the field is not enabled. This is after the invoice was Released. 

public PXAction<ARInvoice> ChangeOrderNbr;
        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "Change Order Nbr", Enabled = false, MapEnableRights = PXCacheRights.Delete, MapViewRights = PXCacheRights.Delete)]
        protected virtual void changeOrderNbr()
        {
            PXUIFieldAttribute.SetEnabled<ARInvoice.invoiceNbr>(base.Base.CurrentDocument.Cache, base.Base.Document.Current, true);

            // Trigger the Save action to save changes in the database.
            // base.Base.Actions.PressSave();
        }

icon

Best answer by Naveen Boga 7 December 2021, 15:44

View original

7 replies

Userlevel 7
Badge +17

Hi @wikusvorster42  It is NOT recommended to write the Enable/Disable related code in actions.

It is always recommended to write this kind of logic in Row_Selected event.

 

Coming to your requirement, you can have a Boolean flag, in the Action logic, you can update the flag based on your requirement.

In Row_Selected event, based on this flag is enabled you can enable/disable the respective fields.

Userlevel 1
Badge

Hi @Naveen B, I did that. Strangely when I do the enable in the Row_Selected it works. When I set a flag and raise event Row_Selected it also doesn’t enable the field.

Just to check, do I do a raise event when calling Row_Selected? That is what I did.

Userlevel 7
Badge +17

@wikusvorster42  Actually, explicit raise event is not required.

Row_Selected event will raise multiple times at code level and it will taken care of enabling/disabling the fields based on the flags.

Userlevel 1
Badge

Thanks @Naveen B, I will give it a try.

Userlevel 7
Badge +17

Sure @wikusvorster42  Let me know if any queries.

Userlevel 1
Badge

Hi @Naveen B, it works like a dream. Thank you very much

Userlevel 7
Badge +17

@wikusvorster42  Awesome :) Thanks for sharing the update.

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