Reputation: 5866
I am new to Dynamics AX and working very hard to learn it. I have created a new table, a new form that displays the table. Everything works fine...
Table has ID, NAME and SURNAME as columns. I want users to enter their name and surname but I want their ID to be unique which would be created by the system. So I disabled ID to be entered by the user.
I have made the ID as primary key but I couldnt figure it out how to make it auto-increment.
Would you please give me hint?
Upvotes: 1
Views: 4412
Reputation: 10345
I was facing the same problem. I found this explanation on MSDN. Find the steps to create number sequences bellow and on this website.
UPDATED
Step 1
Create an EDT - String Type
So, I created an EDT named "AXSeqEDT" with label "AX Seq"
Drag into Table(FirstTable)Fields
Step 2
Now create a new Number Sequence
Path for creating num Sequence is
"Module:: Organization administration.......Common.........Number sequences......Number sequences"
Click on New(Number Sequence)
Now number Sequence form will be opened----That contains 4 sections.
Section 1. Identification.....Specify the NumberSeqCode and Name
Section 2. Scope Parameters... Select the Scope from the Dropdown
Section 3. Segments.... Add the constant and alphanumeric (by clicking the add button and selecting from drop down)
Section 4. General.....Checkmark for continous and Specify the "smallest and largest and Next" Fields
Now Save your Settings
Step 3
Now add the Respective manual-code to class - NumberSeqModuleURMODULE
And Table - URMODULEParameters.
So I am creating number sequence based on HRM Module.....So I am using class NumberSeqModuleHRM and Table HRMParameters
Now go to AOT---Classes-NumberSeqModuleHRM---loadModule()
Note::Here we can add the code seeing the existing implementation
The Added Code is::
/* setup discussion number sequence - it is global */
datatype.parmDatatypeId(extendedtypenum(AXSeqEDT));
datatype.parmReferenceHelp(literalstr("@SYS32633"));
datatype.parmWizardIsContinuous(true);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(99999);
datatype.parmSortField(12);
this.create(datatype);
Now Go to AOT---Tables---HRMParameters---methods-----click on new method
Add the code In the New method
Note::Here we can add the code seeing the existing implementation
The Added Code is
static client server NumberSequenceReference numRefAXSeqEDT()
{
return NumberSeqReference::findReference(extendedTypeNum(AXSeqEDT));
}
Step 4
In order to add our newly created number sequence reference to our Module write the following Job and Execute it
Below 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 sequence loads while restarting the Dynamic AX. In AX 2012 all the number sequence 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.
The Code added in The Job is
static void jobName(Args _args)
{
NumberSeqModuleHRM NumberSeqModuleHRM = new NumberSeqModuleHRM();
;
NumberSeqModuleHRm.load();
}
Step 5
After executing the Above Job, our newly created number Sequence reference "AX Seq" will be added to HRM Module----Number sequence setup form
Lets Check it
Now click on Number Sequence and Identify the newly created Number Seq Reference
After Identifying the Number Sequence Reference ----Allot the Number Sequence Code to the Number Sequence Reference.....By selecting from the drop down list
Step 6
Now add the Code in Create method of Forms Datasource methods
Goto-AOT-Forms-FirstForm-Datasources-FirstTable-Methods-Override method(Create)
public void create(boolean _append = false)
{
;
super(_append);
FirstTable.AXSeqEDT = NumberSeq::newGetNum(HRMParameters::numRefAXSeqEDT(),true).num();
}
Step 7
Now save all your settings.....Now Open our form-FirstForm
Upvotes: 5