I need to fill a field "description" from other field in a screen Acumatica. The problem is that one of the other field contains the identifier of the DAC but I have to retrieve the description and not the identifier.
I tried to do this with a Fluent BQL query in an Event Handler in order to retrieve the single result. var Feurname = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Current<APInvoice.vendorID>>>>.Select(this, BAccount.acctName).First().GetItem();
I have the following error when I test the code : \App_RuntimeCode\APInvoiceEntry.cs(97): error CS0119: 'BAccount.acctName' is a type, which is not valid in the given context
\App_RuntimeCode\APInvoiceEntry.cs(97): error CS0120: An object reference is required for the non-static field, method, or property 'PXSelectBase.Select(params object[])'
Thanks for your help!
So I succeeded by writing the query with LINQ instead of BQL with the following code in the event Handler. Thanks to the contributors. I would be curious to know to do the same with BQL/F-BQL.
var row = e.Row;
VendorMaint graph = PXGraph.CreateInstance();
var query1 = (from p in graph.Select() where p.BAccountID == row.VendorID select p.AcctName).ToList();
string feurname = "";
if (query1.Count > 0)
{ feurname = Convert.ToString(query1[0]); }
else
{ feurname = ""; }
row.DocDesc = feurname;