Home > Back-end >  Acumatica- Update Sales Order from Purchase Order
Acumatica- Update Sales Order from Purchase Order

Time:03-10

I am trying to update a custom field on the SOLine (UsrPOPromisedDate) when the POLine promised date is changed. Below is my graph extension, however SOLine is always null. When I convert the BQL to T-SQL, I get the expected results returned. Why is my view always returning a null value?

using PX.Data;
using PX.KWW.MyProject.DAC;
using PX.Objects.PO;
using PX.Objects.SO;

namespace MyProject.Graph
{
    public class POOrderEntryExt : PXGraphExtension<POOrderEntry>
    {
        public PXSelectJoin<
            SOLine,
            InnerJoin<SOLineSplit,
                On<SOLineSplit.orderType, Equal<SOLine.orderType>,
                And<SOLineSplit.orderNbr, Equal<SOLine.orderNbr>,
                And<SOLineSplit.lineNbr, Equal<SOLine.lineNbr>>>>>,
            Where<SOLineSplit.pOType, Equal<Current<POLine.orderType>>,
                And<SOLineSplit.pONbr, Equal<Current<POLine.orderNbr>>,
                And<SOLineSplit.pOLineNbr, Equal<Current<POLine.lineNbr>>>>>>
            SalesOrderLine;

        protected virtual void _(Events.FieldUpdated<POLine, POLine.promisedDate> eventHandler, PXFieldUpdated baseHandler)
        {
            baseHandler?.Invoke(eventHandler.Cache, eventHandler.Args);

            POLine pOLine = eventHandler.Row;
            if (pOLine is null) return;

            SOLine sOLine = SalesOrderLine.Current;
            SOLineExtension sOLineExtension = sOLine.GetExtension<SOLineExtension>();

            if (sOLine is null || sOLineExtension is null) return;

            sOLineExtension.UsrPOPromisedDate = pOLine.PromisedDate;
            SalesOrderLine.Update(sOLine);
        }
    }
}

CodePudding user response:

Looks like a mistake in your code.

                And<SOLineSplit.pONbr, Equal<Current<POLine.orderType>>,

CodePudding user response:

If you mean SalesOrderLine.Current is null, I don't believe the Current field is populated by default unless the user has selected a specific record within the view(or you manually set it).

If you are just trying to get the records within the view you would need to use SalesOrderLine.Select().

    foreach(SOLine line in SalesOrderLine.Select()){ 
         //Do Something Here
    }
  • Related