How can I skip base logic in SOLine_RowUpdated event

110 views Asked by At

I have a custom code in SOLine_RowUpdated event, my code works fine and that's all I need, but when I finally get the expected value on SOLine.curyUnitPrice field the base event or base logic changes the value.

I would like to know how can I skip the base event or base logic so that my value doesn't change.

This is my SOOrderEntry_Extension graph:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using PX.Common;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects.TX;
using POLine = PX.Objects.PO.POLine;
using POOrder = PX.Objects.PO.POOrder;
using System.Threading.Tasks;
using PX.CarrierService;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Objects.AR.CCPaymentProcessing.Interfaces;
using ARRegisterAlias = PX.Objects.AR.Standalone.ARRegisterAlias;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.CS.Contracts.Interfaces;
using Message = PX.CarrierService.Message;
using PX.TaxProvider;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.Common.Bql;
using PX.Objects;
using PX.Objects.SO;

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {
    #region Event Handlers

    protected void SOLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
    {
        SOLine row = (SOLine)e.Row;

        if (row == null)
        {
            return;
        }

        if (row.SubItemID == null) 
        {
            row.CuryUnitPrice = (decimal?) 0.01;
            return;
        }

        if (row.SubItemID != null)
        {
            if (row.SiteID == null)
            {
                row.CuryUnitPrice = (decimal?) 0.01;
                return;
            }
            
            if (row.OrderQty > 0)
            {
                    return;
            }
            else 
            {
                    string cadena = "MAIN";
                    Location location = PXSelect<Location,
                                                Where<Location.bAccountID, Equal<Required<Location.bAccountID>>,
                                                  And<Location.locationCD, Equal<Required<Location.locationCD>>>
                                                >>.Select(Base, row.CustomerID, cadena);


                  ARSalesPrice salesprice = PXSelect<ARSalesPrice,
                                                    Where<ARSalesPrice.custPriceClassID, Equal<Required<ARSalesPrice.custPriceClassID>>,
                                                        And<ARSalesPrice.inventoryID, Equal<Required<ARSalesPrice.inventoryID>>, 
                                                        And<ARSalesPriceExt.usrSubItemID, Equal<Required<ARSalesPriceExt.usrSubItemID>>,
                                                            And<ARSalesPrice.breakQty, LessEqual<Required<ARSalesPrice.breakQty>>
                                                            >
                                                          >
                                                       >
                                                    >,
                                                    OrderBy<Desc<ARSalesPrice.breakQty>>
                                                >.Select(Base, location.CPriceClassID, row.InventoryID, row.SubItemID, row.Qty);
    
                  if(salesprice == null)
                  {
                      ARSalesPrice salesprice2 = PXSelect<ARSalesPrice,
                                                          Where<ARSalesPrice.custPriceClassID, Equal<Required<ARSalesPrice.custPriceClassID>>,
                                                              And<ARSalesPrice.inventoryID, Equal<Required<ARSalesPrice.inventoryID>>,
                                                              And<ARSalesPriceExt.usrSubItemID, Equal<Required<ARSalesPriceExt.usrSubItemID>>
                                                              >
                                                            >
                                                          >,
                                                          OrderBy<Asc<ARSalesPrice.breakQty>>
                                                      >.Select(Base, location.CPriceClassID, row.InventoryID, row.SubItemID);
                    
                      if (salesprice2 != null)
                      {
                          cache.SetValue<SOLine.curyUnitPrice>(row, salesprice2.SalesPrice);
                      }
                      else
                      {
                          row.CuryUnitPrice = (decimal?) 0.01;
                      }  
                  }
                  else
                  {
                      cache.SetValue<SOLine.curyUnitPrice>(row, salesprice.SalesPrice);
                  }
            }
        }
    }
    #endregion
  }
}

Can you help me with this?

1

There are 1 answers

7
Brian Stevens On BEST ANSWER

You added an event rather than overriding it. You need to specify the appropriate delegate when overriding a base event. Then you can invoke that base event or in your case, not.

using PX.Data;

namespace PX.Objects.SO
{
    public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {
        #region Event Handlers

        protected void SOLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated baseEvent)
        {
            baseEvent.Invoke(cache, e);  //  <- comment out to prevent calling the base event

            // Insert my custom code here
        }
        #endregion
    }
}