Sunday, December 22, 2013

Setting an entity to be dimensionable


To set an entity to be dimensionable, create a view as directed below. The entity will automatically appear as an available backing entity type.
Also, to integrate with the dimensions framework when deleting or renaming the natural key of the backing entity, you must write custom code on the backing table's delete method, and also on either the update or renamePrimaryKey method. See CustTable for an example of the pattern these methods must follow.
1. The view name must be DimAttribute[yourentityname]. For example, DimAttributeCustTable.
2. The view must contain a root data source named BackingEntity that points to your backing table to identify a surrogate key and natural key.
3. The view may optionally contain additional related data sources to handle inheritance or relational associations to provide additional fields, such as a name from the DirPartyTable.
4. The view must contain the following fields named exactly as follows:
Key - Must point to the backing entity's SK field. For example, an int64 RecId field.
Value - Must point to the backing entity's NK field. For example, a str30 AccountNum field.
Name - Must point to the source of an additional description for the entity. For example, a str60 Description field.
5. The view must have a SingularLabel assigned that is different from its Label property.
6. The view must have the same ConfigKey as the backing table.
7. The view must be included in the DimensionEssentials Security Privilege.
Because the list of dimensionable entities are cached on both the client and server, the creation of a new dimensionable entity will not appear in the list of existing entities until a call to clear the caches is performed, or until both the client and the server are restarted. In order to clear the caches and have the new backing entity appear immediately, you must execute the following line of code within a job:
DimensionCache::clearAllScopes();

If a new Organization Model OMOperatingUnitType enumeration is added, the steps to make it dimensionable are similar but can be made shorter as follows:
1. Copy one of the existing DimAttributeOM[entityname] views, rename it appropriately and adjust all associated labels and help text.
2. Expand the Datasource\BackingEntity (OMOperatingUnit)\Ranges node on the copied view and change the value property on the range to the new OMOperatingUnitType enumeration value that was just added.
Because the OMOperatingUnitType is backed by the OMOperatingUnit table, generic code already exists to handle the delete, update and renamePrimaryKey methods. Therefore, in this case, you do not need to update these methods.

Dimensions framework in AX 2012

In Microsoft Dynamics AX 2012, the account and financial dimensions framework has been enhanced to provide
more functionality.
To support this new functionality, the data model has also been completely redesigned.
Therefore, developers will need to update every reference to ledger accounts and financial dimensions
in existing applications to reference the new data model.

Segmented Entry control:
Account form controls combine the Segmented Entry control and a controller class. 
The Segmented Entry control is a general-purpose Microsoft Dynamics AX client control that is being introduced in AX 2012. 
The controller class is an X++ class that handles the events raised by the Segmented Entry control. 
The combination of a control and an underlying class allows the user to see a dynamic number of segments, based on the values the user provides

Main account and ledger account :
In previous versions of Microsoft Dynamics AX, the term ledger account was used to specify what is now referred to as the main account
In AX 2012, the main account is merged with financial dimensions to create a more integrated view of the chart of accounts
In AX 2012 a ledger account contains the main account, account structure, and the financial dimension values that are needed to populate the related account structure ledger account is a 64-bit integer field that contains the data from the corresponding RecId field in the DimensionAttributeValueCombination table

In previous versions of Microsoft Dynamics AX, the term ledger account was used to specify what is now referred to as the main account
In AX 2012, the main account is merged with financial dimensions to create a more integrated view of the chart of accounts
In AX 2012 a ledger account contains the main account, account structure, and the financial dimension values that are needed to 
populate the related account structure ledger account is a 64-bit integer field that 
contains the data from the corresponding RecId field in the DimensionAttributeValueCombination table

Changes needed on the form to add segmented entry control:

Add the LedgerDimension field from the data source to the desired location on the form design. 
This should add a Segmented Entry control at this location on the form with appropriate DataSource and ReferenceField property values.
Or add a Segmented Entry control to the design and manually setting the DataSource and ReferenceField properties

Add the following code in the init method

ledgerDimensionDefaultAccountController =
LedgerDimensionDefaultAccountController::construct(myTable_ds, fieldstr(MyTable, LedgerDimension));

Following methods on the form needs to be overriden for the segemnted control

jumpRef, validate,loadSegment, segmentValueChanged, loadAutoCompleteData, resolveReference(dataSource)

Classes related to dimensions:
Some of the classes can  be used to implement/ make use of dimension framework
DimensionDefaultingController class handles drawing of individual field controls for each financial dimension for the 
current ledger’s account structures, and field entry/validation, lookup, and “view details” functionality
Classes like DimensionDefaultingEngine, DimensionDefaultingService, DimensionStorage etc can be used to perform various operations on dimesnions like get dimension data, build dimesnions etc..

e.g: DimensionStorage::getDefaultDimensionFromLedgerDimension: Gets the default dimension that represents all dimension values from the specified ledger account other than the main account.
DimensionDefaultingEngine::overrideDefaultDimension: Updates a default dimension with the specified dimension values.