Solved

Retriieving Vendor Class

  • 10 September 2021
  • 1 reply
  • 137 views

Good day,

I have added a custom field on the purchase orders screen to display the vendor class under the vendor info tab. This field will be disabled.
I am trying to populate the field after the vendor has been selected on the header.

Please see my code below:

My DAC:

        #region UsrVendorClass
[PXDBString(10, IsUnicode = true)]
[PXDefault()]
[PXSelector(typeof(Search<VendorR.vendorClassID>))]
[PXUIField(DisplayName = "Vendor Class")]

public virtual string UsrVendorClass { get; set; }
public abstract class usrVendorClass : PX.Data.BQL.BqlString.Field<usrVendorClass> { }
#endregion

 

My Graph:

		protected void _(Events.FieldUpdated<POOrder, POOrder.vendorID> e)
{
var row = (POOrder)e.Row;
VendorR vendorClass = new VendorR();
vendorClass = PXSelect<VendorR, Where<VendorR.acctCD, Equal<Current<VendorR.acctCD>>>>.Select(Base, row.VendorID);

POOrderExt extPOOrder = row.GetExtension<POOrderExt>();

extPOOrder.UsrVendorClass = vendorClass.VendorClassID;
}

 

 

Any help would be greatly appreciated, as currently I am getting a NullReferenceException.

icon

Best answer by Kulvir Kaila 10 September 2021, 18:09

View original

1 reply

Userlevel 4
Badge +2

A couple of things.

  • Use Required<> instead of Current<>
  • acctCD is of type string and VendorID is a nullable int so the datatypes don’t line up.  I believe you need to use bAccountID instead of acctCD.

Try the following code

        protected void _(Events.FieldUpdated<POOrder, POOrder.vendorID> e)
{
var row = (POOrder)e.Row;
VendorR vendorClass = PXSelect<VendorR, Where<VendorR.bAccountID, Equal<Required<VendorR.bAccountID>>>>.Select(Base, row.VendorID);

POOrderExt extPOOrder = row.GetExtension<POOrderExt>();

extPOOrder.UsrVendorClass = vendorClass.VendorClassID;
}

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved