Solved

Custom button click event fire twice.

  • 6 December 2023
  • 2 replies
  • 62 views

Userlevel 3
Badge

Hi,

In my graph I’ve a custom button(Verify Vendor) and that button click event fire again press OK on the WebDialogResult popup comes up. 

Here is my screen shot and the click event.

public PXAction<HMRCVendorRegisterDetail> VerifyVendor;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Verify Vendor", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = false)]
protected virtual IEnumerable verifyVendor(PXAdapter adapter)
{
    //Logics here
    
    if(VendorRegisterDetail.Current.BAccountID == null)
    {
        WebDialogResult result = VendorRegisterDetail.Ask(ActionsMessages.Warning, Messages.VendorEmptyMessage,
        MessageButtons.OK, MessageIcon.Warning, true);
    }
    
    return adapter.Get();
}

Can someone help me out to solve this issue?

Thanks

icon

Best answer by Vipul Gajara 6 December 2023, 19:55

View original

2 replies

Userlevel 7
Badge +5

That’s the way it works. Every Ask method eventually throws a special exception that is being handled somewhere up the call stack. To return the execution to the same place, the framework “remembers” the method the exception has been thrown from and re-executes that method once the exception has been dealt with.

 

If your intention is to just show a warning, I’d recommend just putting the warning on a field using RaiseExceptionHandling method instead of using Ask.

 

@bhagyat25, Since you are using a custom Action, PXLongOperation would be a best option to validate and display the message.

PXLongOperation.StartOperation(this, delegate ()
{
if (VendorRegisterDetail.Current.BAccountID == null)
    {
    var message = "Your message here";
    throw new PXException(message);
    }
}); 

 

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