How to create ‘New Number Sequence’


How to create ‘New Number Sequence’ if added new module in AX.
How to create ‘New Number Sequence’ if added new module in AX.
For example I have created a new Module “BasicManagement”
Setp1:
Need to create a new element in the baseenum “NumberSeqModule” as “BasicManagement” .The name should be baseenum should be the Module name.
Step2:
The field which need to be generated as number sequence it should be as extended data type.So create a extended data type and use this in the table.
Step3:
Create a new class as per module name as follows “NumberSeqRefernce_BasicManagement”
Add the following methods

// Modify the class NumberSeqRefernce
Class NumberSeqRefernce_BasicManagementextends NumberSeqReference
{
}
//
public static client server NumberSeqModule numberSeqModule()
{
return NumberSeqModule::BasicManagement;
}
// Methos in  NumberSeqRefernce  which have to modify—Add this code in the last of this method
protected void loadModule()
{
NumberSequenceReference numRef;
;
numRef.dataTypeId = typeId2ExtendedTypeId(typeid(EmpId));
numRef.configurationKeyId = configurationKeyNum(BasicManagement);
numRef.referenceHelp = literalStr("Unique Key for Employee identification.The key is used when creating the Employee");
numRef.wizardContinuous = true;
numRef.wizardManual = NoYes::No;
numRef.wizardAllowChangeDown = NoYes::No;
numRef.wizardAllowChangeUp = NoYes::No;
numRef.wizardHighest = 999999;
numRef.sortField = 1;
this.create(numRef);
}




Step4:
To get the new module number sequence in the Basic > Setup > Number sequences > Number sequences, add the following code in the “NumberSeqReference” class methods
In Construct () method add the following line of code…
case (NumberSeqRefernce_BasicManagement::numberSeqModule()) : return new NumberSeqrefernce_BasicManagement(_module);
In the moduleList() method….
moduleList += NumberSeqrefernce_BasicManagement::numberSeqModule();
Step5: // for set this Number sequence in front End also by set the configure as follow
Go to Basic > Setup > Number sequences > Number sequences there click the Wizard button in the form & click the Next button.
On the next screen, the number sequence for the Module “BasicManagement” will be shown,go further and finish the wizard.
After finishing the wizard select newly created number sequence in Number sequences form and go to General Tab and check the continuous check box
Step6: // Now the main part when we attached this New Number sequence with our form.
Design the form and add the following code in the form
In Form
// Class declaration Method of Form
NumberSeqFormHandler numberSeqFormHandler;
//  Add a new method in FORM METHODS
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::newForm(EmployeeTable::numRefEmpId().NumberSequence,element, EmployeeTable_ds, fieldnum(EmployeeTable, EmpId));
}
return numberSeqFormHandler;
}
// In the data source of form under the table Method
public void create(boolean _append = false)
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(_append);
element.numberSeqFormHandler().formMethodDataSourceCreate();
}




// if user delete a newly enter record (Before Posting) then this code will delete the newly generated Number
public void delete()
{
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
// this method will come under Data source table Method. this will consume the number sequence.
public void write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}

Nothing is Impossible………. Just Believe in This………….. You can do Anything…….
- Harry

Comments

Post a Comment

Thanks

Popular posts from this blog

Connecting to Databases through X++ PART -I

X++ code for document attachment

Multiple Tables In Query