how to create number sequence in module

hi,

could you please help me how to create number sequence in module?

Thanks,

moulali.

Please follow these links, hope It will help you.

http://www.axaptapedia.com/index.php?title=Number_sequences

hi prasan,

Thanks for providing above link. it is very useful for creating number sequence. once again thanks alot.

Thanks,

please follow this link

http://msdn.microsoft.com/en-us/library/aa608474.aspx

Number Sequence Framework This topic describes how to implement the number sequence framework for a new module in Microsoft Dynamics AX. The topic will show how some number sequences could be implemented for the Fleet Management (FM) sample module. (Some of the following steps might be irrelevant if they have been previously performed for other purposes in your new Microsoft Dynamics AX module.) Creating a Parameter Table and a Number Sequence Reference Class The first step to implementing number sequences for a new module is to create a parameter table and a number sequence reference class. 1. Create a parameter table for the new module: MyModuleParameters. For the Fleet Management module, this table is named FMParameters. The table must, at a minimum, contain a Key field and a find method. The delete and update methods must be overridden. These methods can be copied from one of the other parameter tables, such as BOMParameters. 2. Create an enumerated value that represents all of the number sequences for the module by adding a new element to the NumberSeqModule base enum. For the Fleet Management module, the FM element was added to the base enum. Note Configuration keys are used to detect the active number sequence references in your Microsoft Dynamics AX installation. If the configuration key is not enabled, the modules number sequence references are not displayed in the general References form. The user cannot see references from modules that are not enabled. 3. Create a new number sequence reference class named NumberSeqReference_MyModule. This class must extend the NumberSeqReference class. For the Fleet Management module, this class is named NumberSeqReference_FM. 4. Add the numberSeqModule method to the new number sequence reference class. This method must return the element for your module from the NumberSeqModule base enum. The following code shows how this is done for the Fleet Management module. other Copy public static client server NumberSeqModule numberSeqModule() { return NumberSeqModule::FM; } 5. Implement the numberSeqModule and numberSeqReference methods for the parameters table. Copy these methods from one of the other parameter tables such as BOMParameters, and then change the names that are found in the method. Change the return value of the numberSeqModule method so that it references the number sequence class for your module. For example, the numberSeqModule method from the FMParameters table returns NumberSeqReference_FM::numberSeqModule. The numberSeqModule method of the NumberSeqReference_FM class returns NumberSeqModule::FM (the FM element of NumberSeqModule). 6. Add MyModuleParameters::find() as a new line in the selectParameters method of the Company class. The following example shows the line that was added for the Fleet Management module. other Copy FMParameters::find(); 7. Create a form to display the new parameter table. It is important that the functionality of number sequence references is copied exactly from one of the other parameter forms (for example, CustParameters). Remember to change the names of the called methods. 8. In the NumberSeqReference class, add a new line to the construct method—copy one of the existing lines, and then change the name of the class. The following example shows the line that was added for the Fleet Management module. other Copy case(NumberSeqReference_FM::numberSeqModule()) : return new NumberSeqReference_FM(_module); 9. In the NumberSeqReference class, add a new line to the moduleList method—copy one of the existing lines, and then change the name to reference your number sequence class. The following example shows the line that was added for the Fleet Management module. other Copy moduleList += NumberSeqReference_FM::numberSeqModule(); The new number sequence framework is now established. The Number sequences tab should display the “No setup required” message. Making Number Sequence References ________________________________________ Next, you will make number sequence references for the number sequences you are creating for your new module. 1. In your number sequence reference class, override the loadModule method. 2. In this new method, specify the characteristics of each number sequence reference you need in the new module. For example, the following code is from the loadModule method of the NumberSeqReference_FM class. It defines two number sequences used by the Fleet Management module. other Copy protected void loadModule() { NumberSequenceReference numRef; ; // Setup VehicleNum ID numRef.DataTypeId = typeId2ExtendedTypeId(typeid(VehicleNum)); numRef.ReferenceHelp = “Unique key for Fleet Management vehicles”; numRef.WizardContinuous = false; numRef.WizardManual = NoYes::Yes; numRef.WizardAllowChangeDown = NoYes::No; numRef.WizardAllowChangeUp = NoYes::No; numRef.SortField = 1; this.create(numRef); // Setup TripNum ID numRef.DataTypeId = typeId2ExtendedTypeId(typeid(TripNum)); numRef.ReferenceHelp = “Unique key for trips”; numRef.WizardContinuous = false; numRef.WizardManual = NoYes::Yes; numRef.WizardAllowChangeDown = NoYes::No; numRef.WizardAllowChangeUp = NoYes::No; numRef.SortField = 2; this.create(numRef); } Tip For details about how to create a reference, see the comments written above the code for the NumberSeqReference.loadModule method. After creating your references, the system automatically detects them when opening the parameter form. They should now be visible in the grid on the Number sequences tab. Accessing Your New References ________________________________________ For each reference specified in NumberSeqReferenceMyModule.loadModule, you must create a static method on your parameter table. Assuming that you have specified a reference for the MyDataType data type, create the MyModuleParameters::numRefMyDataType method. 1. Copy a numRef method from one of the other parameter tables. 2. Change the name of the method to numRefMyDataType. 3. Add code that will return a number sequence reference object for that specific data type. For example, the following method retrieves the number sequence reference object that is used for the TripNum field. other Copy server static NumberSequenceReference numRefTripNum() { return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(TripNum))); } Using Number Sequences in an Application ________________________________________ To use the number sequence for a form in Microsoft Dynamics AX or in Enterprise Portal, you will typically add code to the data source for the form or data set. You can also retrieve a number sequence value directly in code. For example, the following example retrieves the next available vehicle number from the number sequence used for the VehicleNum field and displays it in the Infolog. other Copy Info(NumberSeq::newGetNum(FMParameters::numRefVehicleNum()).num()); Forms To use a number sequence for a form in Microsoft Dynamics AX, follow these steps. 1. In the classDeclaration method of the form that will be accessing data, add a variable declaration for the number sequence handler. The following example shows the variable definition for a number sequence handler. other Copy public class FormRun extends ObjectRun { NumberSeqFormHandler numberSeqFormHandler; } 2. Add the NumberSeqFormHandler method to the form. The code in this method will create an instance of the number sequence form handler and return it. The following example shows the code that returns the number sequence form handler for the Trips form of the Fleet Management sample module. other Copy NumberSeqFormHandler numberSeqFormHandler() { if (!numberSeqFormHandler) { numberSeqFormHandler = NumberSeqFormHandler::newForm( FMTrips::numRefFMTrips().NumberSequence, element, FMTrips_DS, fieldnum(FMTrips, TripNum)); } return numberSeqFormHandler; } 3. Add create, delete, and write methods to the data source of the table that contains the field for which the number sequence is being used. The following code examples show these methods that are added to the data source for the FMTrips table to support the number sequence for the TripNum field. other Copy public void create(boolean _append = false) { element.numberSeqFormHandler().formMethodDataSourceCreatePre(); super(_append); element.numberSeqFormHandler().formMethodDataSourceCreate(); } public void delete() { element.numberSeqFormHandler().formMethodDataSourceDelete(); super(); } public void write() { super(); element.numberSeqFormHandler().formMethodDataSourceWrite(); } Enterprise Portal To use a number sequence for a form in Enterprise Portal, follow these steps. 1. In the classDeclaration method of the data set that will be accessing data, add a variable declaration for the number sequence handler. The following example shows the variable definition for a number sequence handler. other Copy public class DatSetRun extends ObjectRun { NumberSeqFormHandler numberSeqFormHandler; } 2. Add the NumberSeqFormHandler method to the data set. The code in this method will create an instance of the number sequence form handler and return it. The following example shows the code that returns the number sequence form handler for the FMTripAddEdit data set of the Fleet Management sample module. other Copy NumberSeqFormHandler numberSeqFormHandler() { if (!numberSeqFormHandler) { numberSeqFormHandler = NumberSeqFormHandler::newForm( FMTrips::numRefFMTrips().NumberSequence, element, FMTrips_DS, fieldnum(FMTrips, TripNum)); } return numberSeqFormHandler; } 3. Add create, delete, and write methods to the data source for the data set that contains the field for which the number sequence is being used. The following code examples show these methods that are added to the data source for the FMTrips table to support the number sequence for the TripNum field. other Copy public void create(boolean _append = false) { element.numberSeqFormHandler().formMethodDataSourceCreatePre(); super(_append); element.numberSeqFormHandler().formMethodDataSourceCreate(); } public void delete() { element.numberSeqFormHandler().formMethodDataSourceDelete(); super(); } public void write() { element.numberSeqFormHandler().formMethodDataSourceWrite(); super(); }

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; numRef.wizardManual = NoYes::No; numRef.wizardAllowChangeDown = NoYes::No; numRef.wizardAllowChangeUp = NoYes::No; numRef.wizardHighest = 999999; this.create(numRef); 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. 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() { return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(edt_ComplaintId))); } 4. Create a Form called frm_Complaint. 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 ObjectRun { NumberSeqFormHandler numberSeqFormHandler; } NumberSeqFormHandler numberSeqFormHandler() { if (!numberSeqFormHandler) { numberSeqFormHandler = NumberSeqFormHandler::newForm(Tmt_CallReport::numRefComplaintId().NumberSequence, element, ds_Complaint.dataSource(), fieldnum(tbl_Complaint, ComplaintId)); } return numberSeqFormHandler; } 7. Add the following Methods to the ds_Complaint Data Source: public void create(boolean _append = false) { element.numberSeqFormHandler().formMethodDataSourceCreatePre(); super(_append); element.numberSeqFormHandler().formMethodDataSourceCreate(); } public void delete() { element.numberSeqFormHandler().formMethodDataSourceDelete(); super(); } public void write() { super(); element.numberSeqFormHandler().formMethodDataSourceWrite(); } 8. Your Number Sequence should now function!

Hai moulali

Plz go through this document . may it will be help for you.

8156.To create a numbersequence for the Existing module(pavan).docx (714 KB)

Hai moulali

Plz go through this document . may it will be help for you.

8156.To create a numbersequence for the Existing module(pavan).docx (714 KB)

Google is your friend. Go to Google ask him. It gives you the best solution.

Hi ramya,

Thank you very much for providing number sequence document.

Thanks,

moulali.

hi,

just go through this site

http://daxguy.blogspot.in/2007/04/new-number-sequence-for-new-ax-module.html