Parameter System Design
Pattern AX / D365 FO
The
parameter system design pattern holds static setup information for the modules
in a company, such as information on the national currency, the posting method,
and so on.
The
parameter system should be set up as described in this topic.
The
parameter record is automatically created by the system and has the following:
· A
parameter table
· A
parameter form
· A parameter
menu item
Parameter Table
There
should be one parameter table per module.
Parameter
tables have a single record per company, holding the required parameters for
the module. The record is cached. To enable the Found-cache, a key is defined.
The
following table shows the property setup of the table.
Property
|
Value
|
Description
|
Name
|
MyModuleParameters
|
Module
name (prefix) + "Parameters".
|
Label
|
@....
|
Mandatory.
|
FormRef
|
|
Form
and Menu Item should have the same name as table.
|
TitleField1
|
|
Not
mandatory for parameter tables.
|
TitleField2
|
|
Not
mandatory for parameter tables.
|
Temporary
|
No
|
|
ConfigurationKey
|
|
Mandatory.
|
MaxAccessMode
|
Edit
|
No
add or delete.
|
CacheLookup
|
Found
|
Found
cache activated.
|
CreateRecordIDIndex
|
No
|
Not
needed.
|
SaveDataPerCompany
|
Yes
|
Parameters
are set up per company.
|
TableContents
|
|
Set
according to the contents of the table. Outcome should be default data.
|
Primary Index
|
KeyIdx
|
See
following description of indexes.
|
Cluster
Index
|
KeyIdx
|
See
following description of indexes.
|
TableGroup
|
Parameter
|
Mandatory:
Parameter.
|
Table Fields
Add an
integer field that is named key. It should have the Visible property set to No,
and the Mandatory property set to No (because it holds the value 0).
Add any
other fields for the parameters needed for the module.
Parameter tables have a single unique index named KeyIdx.This
index has a single field: Key. The PrimaryIndex and
ClusterIndex properties on the table get the name of this index.
Table Index
Create a unique index called keyIdx, that consists of the
field key.
Table Methods
The
following code example illustrates how to create a static find method:
client server static MyModuleParameters find()
{
MyModuleParameters parameter;
;
select firstOnly parameter
index Key
where parameter.key == 0;
if (!parameter)
{
Company::createParameter(parameter);
NumberSeqReference::construct(MyParameters::numberSeqModule()).load();
}
return parameter;
}
The
following code example illustrates how to create a delete method:
void delete()
{
throw error("@SYS23721");
}
The
following code example illustrates how to create an update method:
void update()
{
super();
flush MyModuleParameters;
}
In
previous versions, developers added a call to the static find method on the
parameters table in the selectParametersPost method of the Company class.
In
Dynamics 365, this method is no longer available.
Developers
need to add to the onSelectParameters delegate of the Company class. The call
to the static find method goes into the handler.
[SubscribesTo(classStr(Company),
delegateStr(Company, onSelectParameters))]
public static void
Company_onSelectParameters()
{
MyModuleParameters::find();
}
Creation
of the parameters table completed.
Comments
Post a Comment