Hi All,
Welcome to Blog.
Today we are going to learn how to create number sequence. But before we start let's understand about number sequence framework. Microsoft Dynamics AX has a number sequence framework to generate alphanumeric number sequences that are used to identify transaction documents such as purchase orders, Sales Orders. This topic describes how to implement the number sequence framework for a new module in Microsoft Dynamics AX. In this topic will learn how to create new number sequence reference in Accounts Payable module and will use newly created number sequence in our custom form.
Steps to follow one new number using number sequence:
1. Create new string type EDT.
Set label and size properties.
2. Create new class to set Number sequence data type.
Name it like: ModulenameBikeIdNumSeq , My muodulename is Test so I am using Test as prefix for all the objects.
Internal final class TestBikeIdNumSeq extends NumberSeqApplicationModule
{
[SubscribesTo(classstr(NumberSeqGlobal),delegatestr(NumberSeqGlobal,buildModulesMapDelegate))]
static void buildModulesMapSubsciber(Map numberSeqModuleNamesMap)
{
NumberSeqGlobal::addModuleToMap(classnum(TestBikeIdNumSeq), numberSeqModuleNamesMap);
}
public NumberSeqModule numberSeqModule()
{
return NumberSeqModule::Cust;
}
{
NumberSeqDatatype datatype =
NumberSeqDatatype::construct();
datatype.parmReferenceHelp(literalStr("Unique key used for the Bike
iD."));
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardFetchAheadQty(10);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmSortField(1);
datatype.addParameterType(NumberSeqParameterType::DataArea, true,
false);
this.create(datatype);
}
}
3.
Create new runnable class to load
the number sequence.
internal final class
TestBikeIdLoadNumSeq
{
public static void main(Args _args)
{
TestBikeIdNumSeq TestBikeIdNumSeq = new
TestBikeIdNumSeq ();
TestBikeIdNumSeq.load();
}
4.
Build and synchronize your project
and run the above runnable class using below URL.
F&O url/?cmp=dat&mi=sysclassrunner&cls=TestBikeIdLoadNumSeq
5.
After running the job, go the
parameters form you added the number sequence reference to, then, go to the 'Number sequence' tab and verify that a new row is shown.
In my example, I see the new number sequence reference show on the
‘Accounts receivable parameters’ form.
6. Next go to Organization
administration>Number sequences>Number sequences. Then click the 'Generate' button to run the wizard.
Click Next
Finally, review the 'Completed' page, and click 'Finish'.
Remember the number sequence code
generated or find using below filters.
7. Setup new number code on to AR parameter > number sequence > bike id
8.
Create new string type field on
your custom table.
Set extended type property to above
created EDT. Ex- TutBikeId
9.
Override the create method of your
form data source and add below code.
public void create(boolean _append
= false)
{
TestBikeId testBikeId;
NumberSequenceReference numberSequenceReference;
super(_append);
ttsbegin;
numberSequenceReference=
NumberSeqReference::findReference(extendedTypeNum(TestBikeId));
if (numberSequenceReference)
{
testBikeId = NumberSeq::newGetNum(numberSequenceReference).num();
TestTutorialBikeTable.BikeId = testBikeId;
}
ttscommit;
}
10. Build
and synch your project.
11. Create
new record on the form and check.
No comments:
Post a Comment