Skip to main content
Solved

Retriieving Vendor Class

  • September 10, 2021
  • 1 reply
  • 161 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.

Best answer by Kulvir Kaila

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;
        }

 

View original
Did this topic help you find an answer to your question?

1 reply

Kulvir Kaila
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • 61 replies
  • Answer
  • September 10, 2021

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings