Today. this post is about the “Number sequence framework in Ax 2012”. I did get a chance to work on it yesterday and I implemented the number sequence using the white paper available atmsdn. I won’t be discussing the core concepts here, as they are already discussed comprehensively in the white paper, however I will be focusing on the implementation details. I found couple of problems during the implementation and I thought I should discuss those issues and solutions for those. Also I tried simplifying the steps for the uptake of the number sequence, by classifying the steps in categories and providing “a, b, c, d” steps to uptake it.
So firstly the broader picture
To simplify, There are three areas that are controlled by number sequence API as shown in the picture and for each area you need to do code specifically to that particular area to achieve the functionality.
The first two areas(A and B) are related to the Setup and ( C ) part is related to the consumption.
A. Number Sequence Module Setup
i. Create an extended data type that will be storing the Number sequence generated number for your table. We mostly make it string type since we may want to store the company Id with generated number.
ii. Append the module name in the NumberSeqModule
iii. Make a new class with your module name prefix so if you are making Module Abc, you class name would be named NumberSeqModuleABC. This class will add the area in the number sequence administration page.
iv. You need to extend this class with NumberSeqApplicationModule class.
v. Override the loadModule method and add your extended data type reference here. The dataArea line is only needed if you want to provide the user an option in the Module parameters Form, this is my understanding, please correct me on this if I am wrong. This method will create the data types in the NumberSeqDataType data table
protected void loadModule()
{
NumberSeqDatatype datatype = NumberSeqDatatype::construct();
/* Setup application numbers */
datatype.parmDatatypeId(extendedtypenum(TestEdt));
datatype.parmReferenceHelp(literalstr(“@testHelp”));
datatype.parmReferenceLabel(literalstr(“@testLabel”));
datatype.parmWizardIsContinuous(true);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
datatype.parmSortField(1);
datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}
vi. Override numberSeqModule method and return your module just like below
public NumberSeqModule numberSeqModule()
{
return NumberSeqModule::TestModule;
}
vii. Run the job to load your module since the module loading code in Ax 2012 has moved to the check list part, in Ax 2009 the service restart used to perform this action. This is the tricky part because the code written in the whitepaper didn’t work for me and I ran the following job.
static void Job1(Args _args)
{
NumberSeqModuleTestModule obj = new NumberSeqModuleTestModule();
obj.createReferencesForScope();
obj.load();
}
viii. After running job, go to Organization Adminsitration à Number sequences à Number sequences à generate wizard button. Note, whitepaper for Ax 2012 states that there is no need to restart Aos service after that, however you will encounter error here that the module you made does not exist, so you need to restart AO and you are done.
B. Number sequence for the parameter Form
i. If you want to just add your edt to an existing module, just create the edt data type in Module specific number sequence module as mentioned above and include the DataArea there in the parameter type to show here.
ii. One useful tip is, if you are doing try and run on load module code, the changes won’t reflect as each time load module code run, it creates a row for the Number sequence data type in the data type table so you need to remove the row and make sure there is one row for your data type so that API doesn’t get confused when you update the code for your data type.
iii. Go to parameters Form now, add the numberSequencePreInit() method in the Form, just like below
void numberSeqPreInit()
{
runExecuteDirect = false;
numberSequenceModules = [NumberSeqModule::Payroll]; numberSeqApplicationModule = new NumberSeqModulePayroll();
scope = NumberSeqScopeFactory::createDataAreaScope();
NumberSeqApplicationModule::createReferencesMulti(numberSequenceModules, scope);
numberSequenceModules = [NumberSeqModule::Payroll]; numberSeqApplicationModule = new NumberSeqModulePayroll();
scope = NumberSeqScopeFactory::createDataAreaScope();
NumberSeqApplicationModule::createReferencesMulti(numberSequenceModules, scope);
tmpIdRef.setTmpData(NumberSequenceReference::configurationKeyTableMulti(numberSequenceModules));
}
iv. Add numberSequenceReference data source in the Parameter form and add numberSequence table as reference in the data source
v. Make three methods on the data source as above, you can copy it from other Forms like CustParameters and VendParameters Form and you are good to go
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.