NOTE: Please bear with me in this tutorial; I am going to break naming convention best practices, so that my example is clearer.
The first thing you need to do is determine which module you want/need to create the new number sequence for. For this example, I am going create a new number sequence for the “Accounts Receivable” module. Then take the following steps:
Creating a new Number Sequence for the Accounts Receivable Module
1. Create your Extended Data Type that will be used in your table as your Number Sequence field. For this example we will create a string based Extended Data Type called edt_ComplaintId (with a Label property = “Complaint Report”)
2. Next, since we are using the “Accounts Receivable” module, we must modify the proper NumberSeqReference_XXXX Class. Accounts Receivable, actually maps to Customer (or Cust), so we need to make a modification to the NumberSeqReference_Customer class.
We are only concerned with the loadModule() method, and will simply need to add the following code to it:
numRef.dataTypeId = typeId2ExtendedTypeId(typeid(edt_ComplaintId)); numRef.referenceHelp = "Unique key for the Complaint Report"; numRef.wizardContinuous = true;3. After compiling and saving your changes, the next step is to use the Number Sequence Wizard to set it up. Click Basic > Setup > Number sequences > Number sequences to open the form where you can manage your Number Sequences.
numRef.wizardManual = NoYes::No;
numRef.wizardAllowChangeDown = NoYes::No;
numRef.wizardAllowChangeUp = NoYes::No;
numRef.wizardHighest = 999999;
this.create(numRef);
4. Click on the “Wizard” button, which then should initialize the wizard.
NOTE: If you receive an error at this point telling you “The application already has the required number sequences”, this means that you either did not add the definition to an established NumberSeqReference_XXXX Class' (in this example, the NumberSeqReference_Customer Class) loadModule() method, or you have already run the Wizard and set it up.5. Once you arrive on the Wizard Welcome screen, click the Next > button.
6. On the following screen, verify that the Module is “Accounts receivable” and the Reference is “Complaint Report” (which is the label of our Extended Data Type). The Number Sequence code is just an auto-generated value that you can leave as is (Remember this code, so that you can find it in your list of Number Sequences, because you are going to want to make a couple changes to it). Once you have verified the above, click the Next > button.
7. The next screen just gives you an overview, click the Finish button.
8. You should then see your Number Sequence in the list.
9. You will probably want to change the Format to something such as “CR-######”
10. At this point, your Number Sequence is ready for use!
Using the Number Sequence
1. Create a Table and name it tbl_Complaint.
2. Add the edt_ComplaintId Extended Data Type as one of the fields (drag and drop the Extended Data Type directly into the fields of the Table) and name this field ComplaintId.
3. Add the following Method to the tbl_Complaint:
static client server NumberSequenceReference numRefComplaintId()4. Create a Form called frm_Complaint.
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(edt_ComplaintId)));
}
5. Add the tbl_Complaint table to the form’s Data Sources, and name the Data Source ds_Complaint.
6. Add the following Methods to the Form:
public class FormRun extends ObjectRun7. Add the following Methods to the ds_Complaint Data Source:
{
NumberSeqFormHandler numberSeqFormHandler;
}
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::newForm(Tmt_CallReport::numRefComplaintId().NumberSequence, element, ds_Complaint.dataSource(), fieldnum(tbl_Complaint, ComplaintId));
}
return numberSeqFormHandler;
}
public void create(boolean _append = false)8. Your Number Sequence should now function!
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(_append);
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
public void delete()
{
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
public void write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
Hello,
ReplyDeleteI am working Dynamics 6.0 and in the Number Sequence Wizard I am unable to see other modules except for General Ledger.Actually I am unable to post a Free Text Invoice due to the Number Squence Issue...for which I wanted to check in the wizard and there I could'nt find the Accnts Receivable module...Is it possible to add any existing module into it?
Really it was very useful Lasley thank u so much for dis post expectin more lyk dis from u it was simple n easily understandable ...
ReplyDeleteThanks for an excellent post.
ReplyDeleteI'm surprised by something though. You have to go through the wizard to set it up. The process is not completely automated.
Once it is setup in the DEV envronment, how do you move it to production? Do you have to go through the wizard in production as well?
Hi,
ReplyDeletewe can use this code to any module with small changes.
Thanks
Ramesh
Tmt_CallReport -> tbl_Complaint ??
ReplyDeleteSo far, this is the best Number Sequencing content I've found on the internet.
ReplyDeleteQuestion, how well does Number Sequencing play with SQL Server's Auto Increment?
In other words, if I create a new table in the AOT, can I use both or are they mutally exclusive?
Hi
ReplyDeletei am new to Ax environment and having confused about Number sequence , now i got some idea about this.Great post
Thanks
GK
Hi
ReplyDeletei am new to this and your blog helped me lot to understand number sequence.This was the most simple and easiest explaination for the beginner's i have ever read.
Thanks
Diptesh
hi,
ReplyDeletethank you, it was a very helpful article, but I am a bit confused, when I used it to create a number sequence for training courses, it gave me an error ( Tmt_CallReport ) so I changed it by (CompanyInfo) it worked perfectly but I dont know why !!! maybe you can help me...
thanks...
Ahmad
Thank u sir I think this is the most simple way to explain number sequence
ReplyDeletethanks a lot sir for that info
ReplyDelete