Making a Number Sequence Shared in AX 2012

By - June 11, 2013

Note: the instructions to make the following change will make a number sequence shared across ALL companies.  This does not allow you to share across some companies and allow others to have their own, company specific, number sequence.  If you share a Customer number, as used in this example, it is, and will be, shared in every company.

Step 1

static void makeANumberSequenceShared(Args _args)
{
NumberSequenceDatatype              NumberSequenceDatatype;
NumberSequenceDatatypeParameterType NumberSequenceDatatypeParameterType;
//NumberSeqApplicationModule n = new NumberSeqModuleCustomer();
//n.load();
 
ttsbegin;
select forUpdate NumberSequenceDatatype
join forUpdate NumberSequenceDatatypeParameterType
where NumberSequenceDatatype.RecId == NumberSequenceDatatypeParameterType.NumberSequenceDatatype &&
NumberSequenceDatatype.DatatypeId == extendedTypeNum(CustAccount);
//Change the extended data type to the number sequence you want to be Shared (e.g. CustAccount)
if(NumberSequenceDatatype.RecId && NumberSequenceDatatype.ScopeType == 0)
{
NumberSequenceDatatype.ScopeType = 1;
NumberSequenceDatatype.update();
}
if(NumberSequenceDatatypeParameterType.RecId)
{
NumberSequenceDatatypeParameterType.delete();
}
ttsCommit;
}

 

Step 2

Comment out the following line for respective number sequence from NumberSeqModule*** class.

//datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);

 

Step 3

The number sequence will disappear from the parameter form in which it previously existed and will appear in the standard ‘Number sequence’ form (Organization administration>Common>Number sequences>Number sequences) as shown below.

Making a Number Sequence Shared in AX 2012-pic1

 

 

Step 4

Setup a new shared number sequence (e.g. Customer account in this example).  Since the reference no longer exists in the parameters, the reference must be added via the Number sequences form.

Making a Number Sequence Shared in AX 2012-pic2

Once this is completed, again using the customer number as the example, if you go into company FBF and create a new customer, customer 100234 may be created.  If you then jump to company CAN and create a new customer, customer 100235 will be created.  Without modifying Customer creation to use a number sequence in a specific company, you can share the value across all companies.

 

Disclaimer

If the Number Sequence is still visible in the parameter form, or Step 2 was executed before Step 1, an additional step is needed. Use the Job below.

static void MakeANumberSequenceSharedRefresh(Args _args)
{
//Change the NumberSeqModule class  to the class  you altered in step 2
   
NumberSeqApplicationModule n = new NumberSeqModule*** ();
        n.load();
}

 

Receive Posts by Email

Subscribe and receive notifications of new posts by email.