Auto-Numbering Customization

Hi All,

In Acumatica PX.Objects.CS.AutoNumberAttribute is responsible for almost all auto-numbering. However sometimes you may want to have control on it. For example change sequence depend on conditions or add specific numbers related to vendor or customer.
These things quite easy to do with customization. Here I’m going to show you 2 scenarios:

  • How to change numbering sequence
  • How to change new number

Change Numbering Sequence on the fly.
AutoNumber Attribute generates new number on RowPersisting event. As you may remember from T200 Development Training guide RowPersisting of graph will be executed prior to attributes, so we can control what Attributes will do. This is correct for all  *ing events except (RowSelecting).
So on RowPersisting event of Graph you can change Numbering preferences:

protected void CAAdj_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
     AutoNumberAttribute.SetNumberingId<CAAdj.adjRefNbr>(sender, "MYNUMBER");

Of course you also can add conditions:

if (Something != null)
    AutoNumberAttribute.SetNumberingId<CAAdj.adjRefNbr>(sender, "MYNUMBER"); 
    AutoNumberAttribute.SetNumberingId<CAAdj.adjRefNbr>(sender, "HISNUMBER"); 

An surely you can choose different numbering where Manual-Numbering enabled or not.

Acumatica Auto Numbering

Change New Number on the Fly
If you need more control you may consider to customize whole Auto-number attribute. Here I’ll show you the way how can you add suffix dynamically to the number.

First of all lets check where new number is generated. I have mentioned already that it is on RowPersisting Event, but here you can see it on the image:

You also can see that after generation of new number attribute sets it to the field so right after you can see there newly generated value. We can use it in our customization.

Firstly lets create our custom AutoNumbering Attribute where we can add something to the end of the line. To make it simple I just add “AA” suffix to the end of the new number.

Than lets override original attribute with our new one on some screen. I have chosen Allocations:

[MyAutoNumber(typeof(GLSetup.allocationNumberingID), typeof(AccessInfo.businessDate))]

Done. Now we are ready to publish it and test.

As you can see – suffix with AA letter is automatically added after document number generation.

Profit! Have a nice development!

6 Replies to “Auto-Numbering Customization”

  1. Hi.
    I’m not sure if this is the right place to ask.
    I have create few set of numbering for Employee; which have a duplication in number but have different alphabet. This is to differentiate the branch and also the employee level.
    However I heard that it will become a problem later because the system only recognize the number.
    Is it true.

    1. Hi Hanna, Acumatica does support different numbering sequences for Branches and dates.
      It also should work normally if numbers are the same but letters are different. It is just important to have at least one symbol different from another numbering to work.

    1. If you set the numbering to the sequence that is not active, than I think you will have a manual numbering. Setting this can be done from the rowPersisting method, as it is shown here.

  2. Hi Saiful. Numbering sequences are not hard-coded. Usually we have a setup screens like (GL Preferences, Account Receivable preferences and so on) where you choose the name of the numbering.

  3. Hi Sergey,

    Out of curiosity, the autonumbering IDs (eg BATCH, ALLOCATION, VENDOR) is hardcoded/embedded deep in program logic
    or can we change it to, eg BUTCH, ALOKASI, SUPPLIER instead?

    Thank you so much.


Leave a Reply

Your email address will not be published. Required fields are marked *