Share via


Parameter System Design Pattern

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

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. There is one instantiation of this pattern per module.

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.

Aa846438.collapse_all(en-us,AX.60).gifTable 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.

Aa846438.collapse_all(en-us,AX.60).gifTable Index

Create a unique index called keyIdx, that consists of the field key.

Aa846438.collapse_all(en-us,AX.60).gifTable 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; 
}

Create a validateWrite method, if necessary.

Create an initValue method for initializing the table (record) with relevant parameters, even if they have not been set up manually.

Aa846438.collapse_all(en-us,AX.60).gifCall the find Method in the Company Class

Place a call to the find method on your parameter table in the Company.selectParameters method (internal development) or, if you are developing in the higher layers, place the call in the Company.selectParametersPost method.

The selectParametersPost method is at first an empty partner hook. It is called by the standard application after the selectParameters method and is a good option for partners and others to add their extensions to the standard application. This helps make the upgrade process more straightforward.

Parameter Forms

Do not set the TitleDatasource property in the design properties. There is only one record and no identifying key.

Add a tab with number sequences. For more information about how to create a number sequence for a new module, see Number Sequence Framework.

See also

Microsoft Dynamics AX Design Patterns

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.