I need to add "Subaccount Description" column to the DB grid on "Account by Subaccount" form (GL403000). The DAC "GLHistoryEnquiryResult" contains SubCD field which I want to use to link to "Sub" table to get the description. I extended the DAC as the following and modified ASPX. The column header is displayed, but no data in the new column. I tried to extend AccountHistoryBySubEnq Graph. But still not work.
public class GLHistoryEnquiryResultExt : PXCacheExtension<GLHistoryEnquiryResult>
{
[PXString(60, IsUnicode = true)]
[PXUIField(DisplayName = "Subaccount Description")]
[PXDBScalar(typeof(Search<Sub.description, Where<Sub.subCD, Equal<GLHistoryEnquiryResult.subCD>>>))]
public virtual string UsrSubaccountDescription { get; set; }
public abstract class usrSubaccountDescription : PX.Data.BQL.BqlString.Field<usrSubaccountDescription> { }
}
This is for Acumatica 2024 R1 version. Has anyone done this before? I am new to Acumatica. If anyone has a example of adding a column to data grid, that would be helpful. Thanks!
GLHistoryEnquiryResult
is an unbound DAC
, it doesn't exist in the database. More over, your new field is an unbound field
, so there are two reasons why PXDBScalar
doesn't work here.
EnqResult
view (the view behind the grid) has a dataview delegate, this delegate creates GLHistoryEnquiryResult
records.
You need to override this delegate, and populate Sub description there.
I combined the DAC and Graph extensions into one file in the example, but it’s better to split them into two separate files.
using System;
using System.Collections;
using System.Linq;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
namespace PX.Objects.GL
{
public class GLHistoryEnquiryResultExt : PXCacheExtension<GLHistoryEnquiryResult>
{
[PXString(60, IsUnicode = true)]
[PXUIField(DisplayName = "Subaccount Description")]
public virtual string UsrSubaccountDescription { get; set; }
public abstract class usrSubaccountDescription : PX.Data.BQL.BqlString.Field<usrSubaccountDescription> { }
}
public class AccountHistoryBySubEnqExt : PXGraphExtension<AccountHistoryBySubEnq>
{
[PXOverride]
public virtual IEnumerable enqResult(Func<IEnumerable> baseMethod)
{
var result = baseMethod.Invoke().RowCast<GLHistoryEnquiryResult>().ToList();
foreach (var row in result)
{
var sub = (Sub)SelectFrom<Sub>
.Where<Sub.subCD.IsEqual<@P.AsString>>
.View.Select(Base, row.SubCD);
var rowExt = Base.EnqResult.Cache.GetExtension<GLHistoryEnquiryResultExt>(row);
rowExt.UsrSubaccountDescription = sub?.Description;
}
return result;
}
}
}