Reigner Ouano
Reigner Ouano

Reputation: 135

How to setvalue on fieldupdate

Hello i am still having issue on my customization project i am using acumatica and i need to get the corresponding field on pxselect or on field update can you show me a way of doing this i have tried everything that i learned here.

so here is the code i created

 public class APTranExt : PXCacheExtension<PX.Objects.AP.APTran>
        {
            #region UsrWholdingATC
            [PXDBString(10)]
            [PXUIField(DisplayName = "WholdingATC")]
            [PXSelector(
            typeof(Search<withholdingtaxx.atc>),
                typeof(withholdingtaxx.taxRate))]
            public virtual string UsrWholdingATC { get; set; }
            public abstract class usrWholdingATC : PX.Data.BQL.BqlString.Field<usrWholdingATC> { }
            #endregion

            #region UsrWholdingrate
            [PXDBDecimal]
            [PXUIField(DisplayName = "Wholdingrate")]

            public virtual Decimal? UsrWholdingrate { get; set; }
            public abstract class usrWholdingrate : PX.Data.BQL.BqlDecimal.Field<usrWholdingrate> { }
            #endregion

            #region UsrWholdingamount
            [PXDBDecimal]
            [PXUIField(DisplayName = "WholdingAmount")]

            public virtual Decimal? UsrWholdingamount { get; set; }
            public abstract class usrWholdingamount : PX.Data.BQL.BqlDecimal.Field<usrWholdingamount> { }
            #endregion
            [Serializable]
        public class withholdingtaxx : IBqlTable
        {
            #region IDNbr
            [PXDBInt(IsKey = true)]
            [PXUIField(DisplayName = "IDNbr")]
            public virtual int? IDNbr { get; set; }
            public abstract class idNbr : PX.Data.BQL.BqlInt.Field<idNbr> { }
            #endregion

            #region Atc
            [PXDBString(50, IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Atc")]
            public virtual string Atc { get; set; }
            public abstract class atc : PX.Data.BQL.BqlString.Field<atc> { }
            #endregion

            #region Type
            [PXDBString(50, IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Type")]
            public virtual string Type { get; set; }
            public abstract class type : PX.Data.BQL.BqlString.Field<type> { }
            #endregion

            #region Description
            [PXDBString(400, IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Description")]
            public virtual string Description { get; set; }
            public abstract class description : PX.Data.BQL.BqlString.Field<description> { }
            #endregion

            #region TaxRate
            [PXDBString(50, IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Tax Rate")]
            public virtual string TaxRate { get; set; }
            public abstract class taxRate : PX.Data.BQL.BqlString.Field<taxRate> { }
            #endregion

            #region Bir_form
            [PXDBString(50, IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Bir_form")]
            public virtual string Bir_form { get; set; }
            public abstract class bir_form : PX.Data.BQL.BqlString.Field<bir_form> { }
            #endregion
        }
        }

everything from here is working just fine i successfully created a custom table the show table from pxselector

enter image description here

so what i need is when i select atc value i need to also pull the tax rate and put it at wholdingrate field thank you for helping

by the way i tried to put some codes here but it does not hit the fieldupdate when i run at debug mode

protected void APTran_UsrWholdingATC_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {

      var row = (APTran)e.Row;

    }

Upvotes: 0

Views: 725

Answers (1)

Hugues Beaus&#233;jour
Hugues Beaus&#233;jour

Reputation: 8278

it does not hit the fieldupdate when i run at debug mode

Usually this happens because the field editor control doesn't have property CommitChanges set to True:

enter image description here

When CommitChanges is set to True on the editor control the FieldUpdated event will be called when the control lose focus after the user has changed the value:

protected void APTran_UsrWholdingATC_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
  APTran tran = e.Row as APTran;

  if (tran != null)
  {
    APTranExt tranExt = tran.GetExtension<APTranExt>();

    if (tranExt != null)
    {
       decimal? value = [...];
       cache.SetValue<APTranExt.usrWholdingrate>(tran, value);
    }
  }
}

Upvotes: 2

Related Questions