I am afraid there is no easy solution without affecting performance. That's because the rows from grid are not inserted in cache as usual, but generated inside the data view delegate and added with cache.Hold(row);
Therefore the only solution that I found is to add the sales person's name on RowSelected.
(!) Beware this is not recommended by Acumatica customization best practices (although you might find this kind of selects here and there). Just to let you know, the SQL generated query is SELECT TOP (1).
The customization of business logic:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Data;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.GL;
using PX.SM;
using static PX.Objects.Common.Extensions.CollectionExtensions;
using PX.Objects;
using PX.Objects.AR;
using ARDunningLetterList = PX.Objects.AR.ARDunningLetterProcess.ARDunningLetterList;
namespace PX.Objects.AR
{
public class ARDunningLetterListSP : PXCacheExtension<ARDunningLetterList>
{
#region SalesPerson
public abstract class salesPerson : PX.Data.BQL.BqlString.Field<salesPerson> { }
[PXString(60)]
[PXUIField(DisplayName = "Sales Person")]
public virtual string SalesPerson { get; set; }
#endregion
}
public class ARDunningLetterProcess_Extension : PXGraphExtension<ARDunningLetterProcess>
{
public virtual void ARDunningLetterList_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARDunningLetterList row = e.Row as ARDunningLetterList ;
if (row == null) return;
SalesPerson sp = PXSelectJoin<SalesPerson,
InnerJoin<CustSalesPeople, On<SalesPerson.salesPersonID, Equal<CustSalesPeople.salesPersonID>>>,
Where<CustSalesPeople.bAccountID, Equal<Required<CustSalesPeople.bAccountID>>, And<CustSalesPeople.isDefault, Equal<True>>>>.SelectSingleBound(this.Base, null, row.BAccountID);
var rowExt = row.GetExtension<ARDunningLetterListSP>();
rowExt.SalesPerson = sp?.Descr;
}
}
}
Then you add the custom field in the grid.
Note: I've tried other solutions as well (like overriding the data view (adding joined tables), the delegate, or using attributes to calculate the value, but I had no luck).