Upgrading 22r1 -> 23r1? CostCenterID

O.M.G.!!! Did I really just spend 12 hours trying to find the needle in the haystack? Yes. Yes, I did.

If you haven’t made it off of Acumatica 2022r1 yet, this might be one of the most important posts you read on my site as you prepare your code to upgrade to 23r1. As it turns out, there is a field that appears in 2022r1 called CostCenterID, but as far as I can tell, it was a sleeper cell type field. In 23r1, however, this field has become an absolute thorn in my flesh! Don’t let it be one for you!

In 2022r1 and before, attributes like LocationAvail could be used with the following parameters:

   null, null, null)]

However, after moving to 2023r1, many of my custom DAC’s and DAC extensions now require the following syntax:

   null, null, null)]

Did you see the difference? One little required field was added… CostCenterID. When looking into standard code for examples, the field addition is quite simple. Just be sure to add the field to the database script as well when adding to your custom DAC.

#region CostCenterID
public virtual int? CostCenterID { get; set; }
public abstract class costCenterID :
   PX.Data.BQL.BqlInt.Field<costCenterID> { }

Next, be sure to populate the field in the database. (I created my field to allow nulls, but then I had to backfill anyway to get the attributes to stop complaining.) The SQL script to populate it can be as simple as this:

Update MyTable Set CostCenterID = 0 Where CostCenterID Is Null;

Well, all that seems easy enough. Why on earth did it take 12 hours to fix something that turned out to be THIS? Well, my most common debug problem. Problems appear to be rooted in location A, but they almost always turn out to be in Location B.

All afternoon, my page constantly complained that SiteIDType cannot be null. Ok, easy enough. No pointer to where this problem is in the Trace, and my Debug didn’t break for me. No worries! I can remove all references to SiteID in this page and related DAC’s, at least long enough to isolate the problem. Well, you guessed it! The problem wasn’t in THAT page or any DAC defined for that page. It turns out that I had identified the need to add CostCenterID to a DAC included in a PXSelector used on one of my fields. However, I missed the syntax change for LocationAvailAttribute on that particular DAC. Tonight, with my eyes almost glued closed from the mental drain and exhaustion, I finally found it. What do you know? Updating the attribute to include CostCenterID (which I thought I had completed updates previously) magically made all the problems on this page disappear.

There are a few other small changes to watch out for, but CostCenterID is the bane of my existence today. I hope after reading my struggle here that it won’t be so much trouble for you! Just remember to check every DAC that is referenced in a PXSelector, and you should locate the problem quickly. Unfortunately, I didn’t think to follow the PXSelector attributes, so I never got out of the page until I had commented out practically every line of code to find the culprit.

Good luck, and Happy Coding!

Leave a Reply