Tuesday, June 9, 2015

Number Sequence in AX 2012 using X++

Step by step procedure to create number sequence :-

Step 1:- Create a EDT : Esh_StdId

AOT >> Extended Data Types >> New >> Properties >> Name >> Esh_StdId.



Step 2:- Select the Module in which you want to generate the Number Sequence.

EX:-Human Resource
AOT>Classes> NumberSeqModuleHRM >LoadModule

Step 3:- Write a code on lode module() on NumberSeqModuleHRM.


    datatype.parmDatatypeId(extendedtypenum(Esh_StdId));
    datatype.parmReferenceLabel(literalstr("Number Sequence"));
    datatype.parmWizardIsContinuous(true);
    datatype.parmWizardIsManual(NoYes::No);
    datatype.parmWizardIsChangeDownAllowed(NoYes::No);
    datatype.parmWizardIsChangeUpAllowed(NoYes::No);
    datatype.parmWizardLowest(1);
    datatype.parmWizardHighest(999999);
    datatype.parmSortField(20);

    this.create(datatype);

Step 4:- Write a method on HRMParameters Table
Note:- Every Module has there own parameters table as I have selected HRM Module for Number Sequence I am writing the method in HRMParameters Table.


client server static NumberSequenceReference numRefEshId()
{
     return NumberSeqReference::findReference(extendedTypeNum(Esh_StdId));
}

Step 5:- Create a Table and Drag the EDT which you have created to the Table field.


Step 6:- Write a Job to run the programme.


static void Esh_StdId(Args _args)
{
    NumberSeqModuleHRM  numberSeqModuleHRM = new NumberSeqModuleHRM();
    ;
    numberSeqModuleHRM.load();
}



Step 7:- Now run the wizard
Organization Administration >> CommonForms >> Numbersequences>>Numbersequences>> Generate >> run the wizard.

Step 8:- After generating number sequence go to
Human Resource Area Page >> Setup >> Human Resources Shared Parameter



Step 9:- Click on Number Sequence


Step 10:- Select Reference, Right click on it and select View Record and then Click on Number sequence code.


Step 11:- Edit the Number Sequence and add the Segments as show in the picture.


*uncheck continues in General Tab, save the changes and close the form.

Step 12:- Write the job and check whether the number sequence is working correctly


Step 13:- Run the Job and check the generated Number Sequence


Step 14:- Now steps to check the number sequence in table.

Create a initValue Method in Table Method. Copy the Job code and paste in the initValue method of the Table Method as shown in the picture below.



Step 15:- Now Run the Method it will open the table and automatically generate the number Sequence for the assigned field.


Step 16:- Creating Number Sequence at Form Level
Create a New Form and in Data Source Drag and Drop the table for which you have created Number Sequence as shown in the picture below.



Step 17:- Right Click on Design and Select Grid
Drag and Drop the required field from data source to Design Grid and Open the form.
It will show Number Sequence generated in the form as shown in the picture below.


Step 18:- To get the next Record below of the Previous Record, You need to write Create override method in the form DataSource and change the Boolean append type to True as shown in the picture below.


* Now you will get the result as shown in the below picture..


4 comments:

  1. steps 1 to 5 are very confusing and no coordination between the steps and the screens. may be good for a senior developer, but for a novice one, this is not good tutorial. Step one, New what, string, or data, I know it is string, but for junior guy it is confusing, and also Step 3 code shows something and the screen shot shows something else. Very bad. Some times developers want to confuse others in the name of teaching, this guy is master in it.

    ReplyDelete
    Replies
    1. Sorry that it is very confusing for you.. However I don't see any difference in the Step 3 screenshot and code.
      I just tried to help guys like you to understand it clearly with the help of screenshot, i guess it didn't work for you sorry for that.

      Delete
  2. sory numRefeshId it not a class method you don't told about this

    ReplyDelete
  3. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
    Microsoft Dynamics AX Online Training

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...