web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Generate custom Number Sequence for field when created record via "New" Command Button

(0) ShareShare
ReportReport
Posted on by 115

I have set up a custom number sequence in AX 2012 R2. On a form, I have a grid and a Command Button that runs the "New: 260" command. Everything works fine, however I would like to add the functionality that when a user clicks "new" and a new record pops up on the grid, a column on the grid (that is not editable) displays the next number sequence in my custom number sequence. This form is a transaction form (similar to InventTrans); it has an underlying datasource that may contain differing records with any range of the number sequence. The grid on the form only shows the records that belong to the currently generated number sequence, or to the number sequence passed in by the caller.

Any ideas?

*This post is locked for comments

I have the same question (0)
  • RJV Profile Picture
    115 on at

    Ok, so this wasn't actually that bad...

    1. Override the "create" method on the datasource

    2. Put code that looks similar to this. I'm generating a new number sequence in the init method of the form, so that is where "BatchId" comes from.

    3. Code in "create" method on _ds:

    public void create(boolean _append = false)

    {  

       MyTable newRecord;

       super(_append);

       //could put here if you want a custom ID once per line instead of per instance of the form

       //batchId =NumberSeq::newGetNum(RetailParameters::numRefRJV_BatchId(),true).num();

       newRecord = MyTable_ds.cursor();

       newRecord.BatchId = batchId;

    }

  • Suggested answer
    Brandon Wiese Profile Picture
    17,788 on at

    You example does an immediate draw from the number sequence.  If instead you decide that you need to draw but reserve the option to abort the use of that draw, take a look at InventJournalTable and other forms that support this.  They use various NumberSeq classes that support "make decision later" logic required to properly support continuous number sequences.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans