Wednesday, March 12, 2014

Customizing Numbering in Acumatica

Hi Guys,

Acumatica has flexible numbering sequences that allow us to create prefixes, separate numbering sets and basically serves well when there is a uniformity for the numbering for a given screen.

For example, when we issue specific number for specific month or year we can always create separate numbering sets with starting date from effective date for that month or year and problem will be solved.
Here is the example of numbering set for AR payment screen, where each month system will generate numbers for Payment Reference ID starting from predefined prefix and month code:


When we look at AR Setup screen, this numbering sequence ID is specified at Payment Numbering Sequence:

But this example is too simple. What if we need to use special numbering under specific condition. For example, when you do synchronization with external system, Oracle for example, it may be that you are getting Payment ID numbers from there, and need to override the Auto numbering sequence that is in force at your setup. Another words, from Oracle you can get number starting from IV instead of RV and the number itself should be from Oracle, not generated by Acumatica.

To solve it, we can add Numbering Sequence as a custom field to our setup screen. Just add a field to AR Setup, and make it same as other payment numbering sequence fields:

 Here is the customization code behind it:
<DAC type="PX.Objects.AR.ARSetup">
<Field FieldName="UsrARImportID" TypeName="string" MapDbTable="ARSetup" TextAttributes="#CDATA">
<CDATA name="TextAttributes"><![CDATA[[PXDBString(10, IsKey=false, BqlTable=typeof(PX.Objects.AR.ARSetup), IsFixed=false, IsUnicode=true)]
[PXDefault("ARIMPORT")]
[PXSelector(typeof(Numbering.numberingID))]
[PXUIField(DisplayName="Import Numbering Sequence")]]]></CDATA>
</Field>
</DAC>

And then we should create a new Numbering Sequence called ARIMPORT. Here is the hint, if we need number to come automatically from Acumatica, then we should feel it with something, but if number is provided from outside, say MANUALLY, then we can just create the ID ARIMPORT, leaving content blank:
Now next step, somehow we need to identify that the Data Import is going on. We have a special function to do it. So now I will go to the AR screen, then add data event Row Persisting, to the Document Level. Basically the number for the AR Invoice or payment is issued on save :)

Please take note of this.IsImport it changes to True when we do data import from Oracle.
Next we should tell the screen if this is Data Import process, not to use standard numbering sequence but to look at newly defined ARImport one:

So here we only do at Inserting the row, then we create numbering variable and pass whatever we keep in AR Setup, in our case it will be ARIMPORT value. Then we select from table Numbering the content for the ARIMPORT row. If we do have it there, we set autonumber variable to False.

So now we can decide what do we do, we manually populate the number from our Import file or call autonumbering process from ARIMPORT predefined sequence.

I do here manual population from the field UsrOrigRefNbr from the Import file.
But you can use commented code to call AutoNumberAttribute process to generate the number based on ARIMPORT Numbering Sequence content.

All the best,

Sergey.

7 comments:

  1. how to implement the automatic code,,,?
    thank you

    ReplyDelete
    Replies
    1. Hi Mungalim, where you are? Have any Acumatica VAR around, who can help you customizing the solution? Check with our Singapore HQ.

      Delete
  2. how to use autonumber configuration format from numbering sequences to new custom screen?

    ReplyDelete
    Replies
    1. Any help would be appreciated.

      Thanks...

      Delete
    2. Exactly the same way. Add a field to the setup, then use it in the screen code.

      Delete
  3. How can we configure Contacts to have manual numbering so that we can import specific Contact ID values?

    ReplyDelete
  4. Code doesn't seem to work anymore. I'm getting error why I try to publish: 'PX.Objects.AR.ARInvoiceEntry_Extension.ARInvoice_RowPersisting(PX.Data.PXCache, PX.Data.PXRowPersistingEventArgs)': no suitable method found to override

    I'm on version 6.10.1122.12 of Acumatica.

    ReplyDelete