acumaticaacumatica-kb

Adding Customer Class to GLTran \ GLTranR to see in screen GL404000 (Account Details)


I am currently trying to add the customer account class to the viewing area of the GL404000 screen with the by extending the GLTran DAC.

The AccountID, AccountCD and Account name are already available so I thought it would be an easy task.

In GLTranR, I saw where they were pulling in the account data:

public new abstract class referenceID : PX.Data.BQL.BqlInt.Field<referenceID> { }
[PXDBInt()]
[PXDimensionSelector("BIZACCT", typeof(Search<BAccountR.bAccountID>), typeof(BAccountR.acctCD), DescriptionField = typeof(BAccountR.acctName), DirtyRead = true)]
[PXUIField(DisplayName = CR.Messages.BAccountCD, Enabled = false, Visible = false)]
public override Int32? ReferenceID
{
    get
    {
    return this._ReferenceID;
    }
    set
    {
    this._ReferenceID = value;
    }
}

The line that I attempted to change to my need was the [PXDimensionSelector()] however I cannot get this to pull in the class data. Even when I dont change the code at all it will not populate the column.

public new abstract class usrBusinessAccountClass : PX.Data.BQL.BqlInt.Field<usrBusinessAccountClass> { }
protected Int32? _UsrBusinessAccountClass;
[PXDBInt()]
[PXDimensionSelector("BIZACCT", typeof(Search<BAccountR.bAccountID>), typeof(BAccountR.acctCD), DescriptionField = typeof(BAccountR.acctClass), DirtyRead = true)]
[PXUIField(DisplayName = "Business Account Class", Enabled = false, Visible = false)]
      
    public virtual Int32? UsrBusinessAccountClass
    {
      get {return _UsrBusinessAccountClass;}
      set{ _UsrBusinessAccountClass = value;} // set does work but value does not???
    }

just for a test I changed the setter to:

 set { _UsrBusinessAccountClass = 1234; }

And that populated the column with the value 1234, so that is why I think my issue is just with selecting the class.

I would show this but I need 10 rep to post images.


Solution

  • You are on the proper track. The following code shows how to retrieve additional data to display within the screen.

    Non-Database backed field on the DAC you wish to display data on :

    public sealed class GLTranRExtension : PXCacheExtension<GLTranR>
    {
        public abstract class usrClassID : BqlString.Field<usrClassID>
        {
        }
        [PXString(10, IsUnicode = true, InputMask = ">aaaaaaaaaa")]
        [PXSelector(typeof(CRCustomerClass.cRCustomerClassID), DescriptionField = typeof(CRCustomerClass.description))]
        [PXUIField(DisplayName = "Business Account Class")]
        public string UsrClassID { get; set; }
    }
    

    Graph extension in which the extension field is then populated with data :

    public class AccountByPeriodEnqExtension : PXGraphExtension<AccountByPeriodEnq>
    {
        protected virtual void __(Events.RowSelecting<GLTranR> e)
        {
            if(e.Row is GLTranR row)
            {
                GLTranRExtension rowExt = row.GetExtension<GLTranRExtension>();
    
                using(new PXConnectionScope())
                {
                    BAccount bAccount = PXSelectReadonly<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(this.Base, row.ReferenceID);
                    if(bAccount != null)
                    {
                        rowExt.UsrClassID = bAccount.ClassID;
                    }
                }
            }
        }
    }
    

    You will also need to add within the GL404000 the UI elements for your new extension fields. The result will look as follows :

    PopulatedField