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"); 
}
else 
{ 
    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!

Leave a Reply

Please rate*

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