I am trying to add the customer class to the GL301000 Journal transaction form. As you can see from the code, I have created a DAC extension for GLTran, I have also added a database column to the GLTran table called “UsrMissionCustomerClassID” as an int. So, Currently I am just trying to get the refenceID to show up.
So far I have been unable to get anything to show up, and when I run the debugger in Visual Studio
value is always set to null.
I have read through the T series dev guides but I am unsure what to apply to this DAC extension.
What you are asking for is a little bit more complex than just simply adding a DAC field and getting the result in GL Transaction Screen. Here I have added some code for it but I have not tested it. Hopefully, it will work or will give you a head start to warp it up yourself.
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
namespace PX.Objects.GL
{
// DAC Ext
[PXNonInstantiatedExtension]
publicsealedclass GLTranExt : PXCacheExtension<PX.Objects.GL.GLTran>
{
publicstaticboolIsActive() => true;
#region UsrClassNamepublicabstractclass usrClassName : PX.Data.BQL.BqlString.Field<usrClassName> { }
[PXString(60, IsUnicode = true)]
[PXUIField(DisplayName = "Class Name", Enabled = false, Visible = true)]
publicstring UsrClassName { get; set; }
#endregion
}
// Graph Extpublicclass JournalEntryExt : PXGraphExtension<PX.Objects.GL.JournalEntry>
{
publicstaticboolIsActive() => true;
protectedvoid _(Events.FieldSelecting<GLTran, GLTranExt.usrClassName> e)
{
var row = (GLTran)e.Row;
if (row == null) return;
if (row.Module == "AR" && row.ReferenceID != null)
{
Customer account = PXSelect<Customer,
Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, row.ReferenceID);
if (account != null) return;
CustomerClass accountClass = PXSelect<CustomerClass,
Where<CustomerClass.customerClassID, Equal<Required<CustomerClass.customerClassID>>>>.Select(Base, account.CustomerClassID);
if (accountClass == null) return;
e.ReturnValue = accountClass.Descr;
}
if (row.Module == "AP" && row.ReferenceID != null)
{
Vendor account = PXSelect<Vendor,
Where<Vendor.bAccountID, Equal<Required<Vendor.bAccountID>>>>.Select(Base, row.ReferenceID);
if (account != null) return;
VendorClass accountClass = PXSelect<VendorClass,
Where<VendorClass.vendorClassID, Equal<Required<VendorClass.vendorClassID>>>>.Select(Base, account.VendorClassID);
if (accountClass == null) return;
e.ReturnValue = accountClass.Descr;
}
}
}
//Do not forget to ADD the "UsrClassName" to the Grid in your screen and set the CommitChanges = True
}
Based on what you’ve described, you’ve added the column to the database table and the DAC. The value, however, will be null until you assign it.
What’s your intention on how to populate the contents of this field? Automatically based on the value of another field in the same record? Or during data entry?
I am trying to make it happen automatically, I am thinking that I can pull form the referenceID column and work my way back to a customer class with a search.
at one point I was trying to us just:
[PXFormula(GLTran.referneceID)]
and that way filling in the referenceID, however when I tried to expand it into a search I couldn’t get it to show anything.
What you are asking for is a little bit more complex than just simply adding a DAC field and getting the result in GL Transaction Screen. Here I have added some code for it but I have not tested it. Hopefully, it will work or will give you a head start to warp it up yourself.
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
namespace PX.Objects.GL
{
// DAC Ext
[PXNonInstantiatedExtension]
publicsealedclass GLTranExt : PXCacheExtension<PX.Objects.GL.GLTran>
{
publicstaticboolIsActive() => true;
#region UsrClassNamepublicabstractclass usrClassName : PX.Data.BQL.BqlString.Field<usrClassName> { }
[PXString(60, IsUnicode = true)]
[PXUIField(DisplayName = "Class Name", Enabled = false, Visible = true)]
publicstring UsrClassName { get; set; }
#endregion
}
// Graph Extpublicclass JournalEntryExt : PXGraphExtension<PX.Objects.GL.JournalEntry>
{
publicstaticboolIsActive() => true;
protectedvoid _(Events.FieldSelecting<GLTran, GLTranExt.usrClassName> e)
{
var row = (GLTran)e.Row;
if (row == null) return;
if (row.Module == "AR" && row.ReferenceID != null)
{
Customer account = PXSelect<Customer,
Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, row.ReferenceID);
if (account != null) return;
CustomerClass accountClass = PXSelect<CustomerClass,
Where<CustomerClass.customerClassID, Equal<Required<CustomerClass.customerClassID>>>>.Select(Base, account.CustomerClassID);
if (accountClass == null) return;
e.ReturnValue = accountClass.Descr;
}
if (row.Module == "AP" && row.ReferenceID != null)
{
Vendor account = PXSelect<Vendor,
Where<Vendor.bAccountID, Equal<Required<Vendor.bAccountID>>>>.Select(Base, row.ReferenceID);
if (account != null) return;
VendorClass accountClass = PXSelect<VendorClass,
Where<VendorClass.vendorClassID, Equal<Required<VendorClass.vendorClassID>>>>.Select(Base, account.VendorClassID);
if (accountClass == null) return;
e.ReturnValue = accountClass.Descr;
}
}
}
//Do not forget to ADD the "UsrClassName" to the Grid in your screen and set the CommitChanges = True
}
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.