Autonumbering In Acumatica


Today I want to share with you how I implemented autonumbering feature in acumatica for page CA304000.

My task originally was the following: add autonumbering feature to the "Document Ref" field with following rules:

  a. step of incrementing is 1

  b. length of field should be six characters. For example 000001, 000002, ... ,  000223,  001024, ..., and so on

First of all I want to state that my way of adding much simpler then "canonical" ( according to acumatica manuals ) way of adding autonumbering.  If you wish to use standard way you should accomplish so many steps that I should admit that my brain wasn't able to boil them in one project. 

Instead of this I used the following steps.

1. In the page CA304000 I found class, which provides data for the page. It looks like this:

<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" PrimaryView="CAAdjRecords" TypeName="PX.Objects.CA.CATranEntry">

2. Created extention of class in the following way:

public class CATranEntryExt : PXGraphExtension<CATranEntry>

3. Located method which returns list of records for the page CA304000, it was the method: CAAdjRecords.

4. According to rules of acumatica, if I want to modify behaviour of method CAAdjRecords I should implement method caadjrecords.


protected virtual IEnumerable caadjrecords()

6. Implemented method which digs in DB, and returns needed number in string format:

protected string GetExtRefNbr()
            var maxNbr = 1;
            foreach (var cAddjRec in PXSelect<CAAdj>.Select(Base, new byte[0]))
                var extRefNbr = ((CAAdj) cAddjRec).ExtRefNbr;
                int curNbr = 0;
                if (int.TryParse(extRefNbr, out curNbr))
                    maxNbr = curNbr + 1;
            var result = maxNbr.ToString(CultureInfo.InvariantCulture).PadLeft(defaultLength, '0');
            return result;

7. Used GetExtRefNbr in the method caadjrecords in the following way:

protected virtual IEnumerable caadjrecords()
            var res = new List<CAAdj>();
            var availableCashAccounts = GetAvailableCashAccounts();

            foreach (
                var doc in
                    PXSelect<CAAdj, Where<CAAdj.draft, Equal<False>>>.Select(Base, new byte[0]))
                if (((CAAdj)doc).RefNbr.Contains("NEW"))
                    ((CAAdj) doc).ExtRefNbr = GetExtRefNbr();
            return res;

8. Enjoyed results:

the field Document Ref.: was inserted automatically.


  • Angie Osorno said


    It's me, again hahaha

    I read your articule

    I read your article but I get it ... in my case I have a custom screen that I want to generate the automatic numerical value, but I do not know how.

    could you it teach me how you do?

  • docotor said 

    Describe a bit more what kind of autonumbering you need?

  • angie said 


    I have selector that it have to search registers about your numbering

    for example, how invoice screen it do...

    I sent an email to you

  • docotor said 

    I can't say that I understood what you mean.


Comments are closed