Create Custom Financial Dimension in AX 2012

In the Financial dimensions list we have standard dimension list provided by Microsoft. If we want to have custom dimension you have to select custom dimension & define the values. What if we want to work custom dimension just like the standard dimension eg. ProjId. The Proj Id dimension dropdown shows the projects from view. So lets create a "Project Quotation Id" custom dimension just like ProjId standard dimension.



Project quotation Id is not in the standard list of dimension. Follow the below steps to create one.
1. Create a view which points to the SalesQuotationTable & define the fields as shown below.
2. The Key Field points to RecId of SalesQuotationTable
3. Value -> QuotationId
4. Name -> QuotationName



5. Customize the DimensionEnabledType class by writing a server static method as below

public static server DimensionEnabledType ABC_constructForQuotationId(RecId _financialTagCategoryId = 0, TableLabel _viewLabel = '')
{
    DimensionEnabledType          dimEnabledType;
    DimensionAttribute            dimAttr;
    DimensionAttributeDirCategory dimAttrDirCategory;
    DimensionValueTranslationContract dimValueTranslationContract;

    // User defined lists differ from system defined as they are stored in 1 table with a category type qualifier
    dimEnabledType = new DimensionEnabledType();
    dimEnabledType.parmViewName(tableStr(<Your view name>));
    //dimEnabledType.parmFinancialTagCategoryId(_financialTagCategoryId);
    dimEnabledType.parmBackingEntityTableName(tableStr(<Your view name>));
    dimEnabledType.parmBackingEntityKeyFieldName(fieldStr(<Your view name>, RecId));
    dimEnabledType.parmBackingEntityValueFieldName(fieldStr(<Your view name>, Value));

     // Only 1 dimension attribute can use a particular user defined list, so use its name as the label; as the financial tag doesn't have a natural key
    if (_financialTagCategoryId && (_viewLabel == ''))
    {
        select firstonly Name from dimAttr
            where dimAttr.Type != DimensionAttributeType::DynamicAccount
            join RecId from dimAttrDirCategory
                where dimAttrDirCategory.DirCategory == _financialTagCategoryId &&
                    dimAttr.RecId == dimAttrDirCategory.DimensionAttribute;

        dimEnabledType.parmViewLabel(dimAttr.Name);
    }
    else
    {
        dimEnabledType.parmViewLabel(_viewLabel);
    }

    return dimEnabledType;
}

6. Customize the class DimensionDetails -> classDeclaration method. Add the macro for dropdown list Quotation Id position.

#define.BackingEntitySelection_Quote(36)

7. Customize the class DimensionDetails -> run method. Put the below line of code in the end of method

entityList.add("QuotationId");

8. Customize the class DimensionDetails -> entityList_SelectionChange method. Put the below line of code after the if statement

 else if(selection == #BackingEntitySelection_Quote)
    {
        this.linkDimensionAttribute(DimensionEnabledType::ABC_constructForQuotationId());
        this.enableMask(true);
        // Default in the name from the backing entity if currently blank or matched the previous entity name
        if (dimensionAttribute.Name == '' || (previousName == previousEntityName))
        {
            dimensionAttribute.Name = "QuotationId";
        }

    }

9. Customize the class DimensionDetails -> dimensionAttribute_active method. Put the below line of code after the if statement

 else if(dimensionAttribute.BackingEntityType == tableNum(<Your view name>))
        {
            // All other existing entities
            wasOriginallyCustom = false;
            entityList.selection(#BackingEntitySelection_Quote);

        }
10. Generate incremental CIL. If required clear usage data. 
11. Check the dimension values by creating a new Financial dimension by selecting QuotationId from dropdown list. In the Financial Dimension Values form you will see the Quotation Ids. 
12. If you want to enable this dimension modify the Dimension structure & you will see it on the forms.

Comments

Post a Comment

Popular posts from this blog

Sales order invoice posting using X++ with custom SalesParmLine fields

Create a custom lookup with multiple data sources on form using X++

SalesTable2Line custom field update prompt on Sales order in AX 2012