Alerts for Number sequence numbers running out

we recently faced a problem where a number sequence reached its limit, although it was a bug in configuration and number sequence should be set to range like 9 digits 999,999,999, but this query below can be used to identify the number sequence which are reaching to its limit. 
One can setup some alerts or some batch job that may be run on monthly basis and produce number sequences that are reaching consumption to let say 70%

 SELECT [NUMBERSEQUENCE]  
    ,[TXT]  
    ,[LOWEST]  
    ,[HIGHEST]  
    ,[NEXTREC]  
       ,100 * (NEXTREC - LOWEST)/(HIGHEST - LOWEST) as 'Percent Consumed'   
  FROM [dbo].[NUMBERSEQUENCETABLE]  
  where (NEXTREC - LOWEST) >= (HIGHEST - LOWEST) * 0.2  

 

New Number sequence Implementation in Dynamics AX 2012

In Dynamics ax 2012, there are number of enhancement in number sequence framework and implementation as well, i will discuss the enhancement in my future blogs, here are the simple steps that needs to follow to implement it.

1 Created a new EDT
2. Added the code in the class NumberSeqModuleProject method loadModule() , see existing implementations in the loadModule method for reference.
3. Created a new method in the table ProjParameters to access the next sequence number. The method should return your module enum and also one method for each datatype (check existing implementations in the ProjParameters table)
4. Write a job that initiates your class and call the loadModule method

static void jobName(Args _args)
{
    NumberSeqModuleProject  NumberSeqModuleProject = new NumberSeqModuleProject();
    ;
    NumberSeqModuleProject.load();
}


Above job is important to run because without it your new number sequence will not be available to number sequence form under Parameters. This is the change in behavior from AX 2009 where all new number sequnce loads while restarting the Dynamic AX. In AX 2012 all the number seuqnce created to system while installation, so restarting the AOS wont effect in loading the new number sequence, that is why it is important to run the job to load new number sequences.

For implementation of new number sequence in new Module you should create a class following below steps

1.Add the NumberSeqModule enum with your module.
2. Create a new class for your numSeq which extends NumberSeqApplicationModule class with the standard methods (check existing implementation for any module like Project)
3. In the loadModule you put all your datatypes for which you want to create number sequence, again follow any existing class for the implementation.
4. rest of the steps are same that you need to create a job to load the new number sequences.

Number sequence implementation in Dynamics ax

You can download the document for implementing the number sequence form here