Create ETD
Str type ;
Create the
table and add that Edt to that table
Create the
form With the same name of the table
1.
Step:-
Open the NumberSeqModuleCustomer class in the Application
Object Tree (AOT), and add the following code to the bottom of the loadModule() method:
NumberSeqDatatypedatatype =
NumberSeqDatatype::construct ();
;
datatype.parmDatatypeId(extendedTypeNum(CustGroupId));
datatype.parmReferenceHelp("Customer
group ID");
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::Yes);
datatype.parmWizardIsChangeUpAllowed(NoYes::Yes);
datatype.parmWizardHighest(999);
datatype.parmSortField(20);
datatype.addParameterType(
NumberSeqParameterType::DataArea,
true, false);
this.create(datatype);
2.Step:-
2. Create a
new job with the following code and run it:
static
void NumberSeqLoadAll(Args _args)
{
NumberSeqApplicationModule::loadAll();
}
3.Step:-
Run the
number sequence wizard by clicking on the Generate button in Organization
administration | Common | Number sequences | Number sequences, and click on the
Next button, as shown in the following screenshot:
4.
step:-
Click on
Details to view more information. Delete everything apart from the lines where
Area is Accounts receivable and Reference is Customer group. Note the number
sequence codes, and click on the Next button:
5.step:-
On the last
page, click on the Finish button to complete the set up:
6.step:-
The newly
created number sequences can now be found in Organization administration |
Number sequences | Number sequences, as shown in the following screenshot:
7.step:-
Open
Organization administration | Number sequences | Segment configuration and
notice the new Customer group reference:
8.Step:-
Open
Accounts receivable | Setup | Accounts receivable parameters and go to the
Number sequences tab page. Here we should see the new number sequence code:
9.Step:-
The last
thing to do is to create a helper method for this number sequence. Locate the CustParameters table in the AOT and create the following
method:
public
server static NumberSequenceReference numRefCustGroupId()
{
return
NumberSeqReference::findReference(
extendedTypeNum(CustGroupId));
}
How
it works...
We start
the recipe by adding a number sequence initialization code into the
NumberSeqModuleCustomer class. As we can understand from its name, it holds the
initialization of all number sequences that belong to the Accounts receivable
module.
The code in
the loadModule() method defines the default number sequence settings to be used
in the wizard, such as data type, description, highest possible number, and so
on. Additional options, such as starting sequence number, number format, and
others could also be added here. All mentioned options could be changed while
running the wizard. The addParameterType() method is used to define number
sequence scope. In the example we created a separate sequence for each Dynamics
AX company.
Before we
start the wizard, we need to initialize number sequence references. This is
normally done as a part of the Dynamics AX initialization checklist, but in
this example we have to execute it manually by calling the loadAll() method of
the NumberSeqApplicationModule class.
Next, we
will run the wizard. We will skip the welcome page and in the second step of
the wizard, the Details button can be used to display more options. The options
can also be changed later in the Number sequences form before or even after the
number sequence is actually used. The last page shows an overview of what will
be created. Once completed, the wizard creates new records in the Number
sequences form for each company.
The newly
created number sequence reference appears in the Segment configuration form.
Here we can see that the Data area checkbox is checked, meaning that we will
have separate number lists for each company. The number sequence setup can
normally be located in the module parameter forms.
10
.Step:-
In the AOT,
open the CustGroup form and add the
following code to its class declaration:
NumberSeqFormHandler
numberSeqFormHandler;
11.
Step:-
Also, create a new method called numberSeqFormHandler() in
the same form:
public
NumberSeqFormHandler numberSeqFormHandler()
{
if
(!numberSeqFormHandler)
{
numberSeqFormHandler
= NumberSeqFormHandler::newForm(
CustParameters::numRefCustGroupId().NumberSequenceId,
element,
CustGroup_ds,
fieldNum(CustGroup,CustGroup));
}
return
numberSeqFormHandler;
}
12.step:-
In the same
form, override the CustGroup data source's create()
method with the following code:
public
void create(boolean _append = false)
{
element.numberSeqFormHandler().formMethodDatasourceCreatePre();
super(_append);
element.numberSeqFormHandler().formMethodDatasourceCreate();
}
13.step:-
In the same
data source, override its delete() method with
the following code:
public
void delete()
{
ttsBegin;
element.numberSeqFormHandler().formMethodDatasourceDelete();
super();
ttsCommit;
}
14.Step:-
In the same data source, override its write() method with the
following code:
public
void write()
{
ttsBegin;
super();
element.numberSeqFormHandler().formMethodDatasourceWrite();
ttsCommit;
}
15.Step:-
In the same data source, override its validateWrite() method with
the following code:
public
boolean validateWrite()
{
boolean
ret;
ret
= super();
ret
= element.numberSeqFormHandler().formMethodData sourceValidateWrite(ret)
&& ret;
return
ret;
}
16.Step:-
In the same
data source, override its linkActive() method with
the following code:
public
void linkActive()
{
element.numberSeqFormHandler().formMethodDatasourceLinkActive();
super();
}
17.Step:-
Finally, override the form's close() method with the
following code:
public
void close()
{
if
(numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
18.Step:-
In order to
test the numbering, open Accounts receivable | Setup | Customers | Customer
groups and try to create several new records—the Customer group value should be
generated automatically:
19.Step:-
How it
works...
First, we
declare an object of type NumberSeqFormHandler in
the form's class declaration. Then, we create a new corresponding form
method numberSeqFormHandler(), which instantiates the object if it is not yet
instantiated and returns it. This method allows us to hold the handler creation
code in one place and reuse it many times within the form.
In the
method, we use the newForm() constructor of the
NumberSeqFormHandler class to create the numberSeqFormHandler
object. It accepts the following arguments:
The number
sequence code, which was created in the prerequisite recipe, and which ensures
a proper format of the customer group numbering. Here, we call the
numRefCustGroupId() helper method from the CustParameters table to find which
number sequence code should be used when creating new customer group record.
The form
object itself.
The form
data source where we need to apply the number sequence handler.
The field
number of the field into which the number sequence will be populated.
Finally, we
add various NumberSeqFormHandler methods to the corresponding methods on the
form's data source to ensure a proper handling of the numbering when various
events are triggered.
No comments:
Post a Comment