Default Customer Location not updating custom fields

  • 19 November 2021
  • 4 replies

Hey all,

I have and issue and I am trying to see if anyone else has seen this issue or may know what may be causing this.  We have custom fields on the Locations table and a customization that populates these fields when a new Customer/Vendor Location is added.  In 2020 R1, this customization worked on all added location.   In 2021 R1, this customization works great except for the first initial “Main” Location that gets created automatically when you create a new Customer/Vendor.  Does anyone have any ideas why the automatically created location skips any custom code but all subsequent ones don’t.





Best answer by jinin 22 November 2021, 17:39

View original

4 replies

Userlevel 3

@mgygi76 It depends on what event and how you have written the code to populate the custom fields. So, it would be helpful for us to review, if you can share the piece of code that you have written to populate the custom fields.



I have a custom function that does a bunch of lookups and assigns the values but the problem isn’t in the code that function.  I have linked this function to different events on the Location table (field updating, row inserting, etc.).  I have put a couple examples where I have these updates.  I cannot get Acumatica to break on any of these events on that first automatic “Main” Location creation but it does on any user created one.  You can even go into that default location after its been created, change the values and then these events will fire. UpdateLocationTerritory is the function that sets the custom field values.


protected void _(Events.RowInserting<Location> eventHandler)
            Location row = eventHandler.Row;
            if (row is null) return;

            UpdateLocationTerritory(eventHandler.Cache.Graph, row);


 protected void _(Events.FieldUpdated<Address, Address.postalCode> eventHandler)
                Updates the SalesTerritoryCD on the Location when
                the Address PostalCode changes.

            Address row = eventHandler.Row;
            Location location = Base.Location.Current;

            if (row is null || location is null)

            UpdateLocationTerritory(eventHandler.Cache.Graph, location);

Userlevel 3
Badge +1

Tested on 2021 R1 Build 21.110.0032 and I was getting debugging breaks on the default inserted location.

using PX.Data;
using PX.Objects.AR;
using Location = PX.Objects.CR.Standalone.Location;

namespace Temp
public class CustomerMaintExt : PXGraphExtension<CustomerMaint>
public static bool IsActive() => true;

public void _(Events.RowInserting<Location> e)
//Insert Code Here



Userlevel 3
Badge +1

Hi @mgygi76 

We can try the below approach as well. When we save the location, get the details from the Default location and assign to the respective fields.

Please review the below sample.

 public class KNMCCustomerLocationMaintExtn : PXGraphExtension<CustomerLocationMaint>
        public static bool IsActive() { return true; }

        #region Action
        public void Persist(Action del)
            if (Base.LocationCurrent.Cache.GetStatus((object)Base.LocationCurrent.Current) == PXEntryStatus.Inserted)
                CustomerMaint customerGraph = PXGraph.CreateInstance<CustomerMaint>();
                customerGraph.CurrentCustomer.Current = PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, Base.LocationCurrent.Current.BAccountID);

                if (customerGraph.CurrentCustomer.Current != null)
                    var defLocationExt = customerGraph.GetExtension<DefLocationExt>();
                    defLocationExt.DefLocation.Current = defLocationExt.DefLocation.Select();                  

                    Base.LocationCurrent.Current.CShipTermsID = defLocationExt.DefLocation.Current?.CShipTermsID;
                    Base.LocationCurrent.Current.CCarrierID = defLocationExt.DefLocation.Current?.CCarrierID;
                    Base.LocationCurrent.Current.CTaxZoneID = defLocationExt.DefLocation.Current?.CTaxZoneID;





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 — 2020  Acumatica, Inc. All rights reserved