Solved

Update PXDBBool from a Command Button

  • 14 November 2023
  • 2 replies
  • 33 views

Userlevel 1
Badge

Im trying to click on a simple command button on the SOOrder screen that sets another bound boolean field on the form. The comman button seems to fire but I cant seem to get the checkbox boolean field to set and update the database? Please help!!

 

PXAction logic after clikcing ASSEMBLE KITS REQUEST (exception gets thrown “Request Sent”)

  public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{


public PXAction<PX.Objects.SO.SOOrder> UsrKitsAssembleReq;

[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Assemble Kits Request")]
public virtual IEnumerable usrKitsAssembleReq(PXAdapter adapter)
{
SOOrderExt1 soOrderExt = Base.Document.Current.GetExtension<SOOrderExt1>();
Base.Document.Cache.AllowUpdate = true;
Base.Transactions.Cache.AllowUpdate = true;
soOrderExt.UsrKitsAssembleReq = true;
throw new PXException("Request Sent");
return adapter.Get();
}

DAC Extension for Kit Assembly Request Boolean:

        #region UsrKitsAssembleReq
[PXDBBool]
[PXUIField(DisplayName="Kit Assembly Request?")]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
public bool? UsrKitsAssembleReq{ get; set; }
public abstract class usrKitsAssembleReq: PX.Data.BQL.BqlBool.Field<usrKitsAssembleReq> { }
#endregion

 

icon

Best answer by Naveen Boga 14 November 2023, 08:07

View original

2 replies

Userlevel 7
Badge +17

@Dantheman88988  Please try with the below code.

 public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
public PXAction<PX.Objects.SO.SOOrder> UsrKitsAssembleReq;

[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Assemble Kits Request")]
public virtual IEnumerable usrKitsAssembleReq(PXAdapter adapter)
{
if (Base.Document.Current != null)
{
SOOrderExt1 soOrderExt = Base.Document.Current?.GetExtension<SOOrderExt1>();
soOrderExt.UsrKitsAssembleReq = true;
Base.Document.Cache.Update(Base.Document.Current);
Base.Save.Press();
throw new PXException("Request Sent");
}
return adapter.Get();
}
}

 

Userlevel 1
Badge

Thanks v much Naveen!

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