Financial dimensions display on form
Financial dimensions is a complex topic since AX 2012, same in D365FO. They can vary for every installation done.
Lately I got a request to display the financial values and that they should also be available to use as filters. I started the task and tried to use the "Add financial dimensions for ODATA" addin. But for some reason I could not make it work and consistently get the error:
The form datasource: 'DimensionSetEntity' is bound to an unsupported entity type
As an alternative I did it the old fashioned way, by the means of a view and some code in a helper class.
You will need a helper class which fetches your dimension attributes individually, these will be hard coded as they will not change.
- Helper class
- View with methods
- Add methods as computed fields to view
- Add view to form
- Override form datasource
Process
1. Create a helper class
Name: FinancialDimensionHelper_[YourPostfix]
Methods: one for each financial dimension:
Code:
private boolean shouldUseRetailPricingDataManagerV3()
internal final class FinancialDimensionHelper_[YourPostFix]
{public static DimensionAttribute getDimensionAttributeBusinessUnit(){return FinancialDimensionHelper_[YourPostFix]::getDimensionAttribute('BusinessUnit', 'BusinessUnit');}public static DimensionAttribute getDimensionAttributeCountry(){return FinancialDimensionHelper_[YourPostFix]::getDimensionAttribute('Country', 'Country');}public static DimensionAttribute getDimensionAttributeDepartment(){return FinancialDimensionHelper_[YourPostFix]::getDimensionAttribute('Department', 'Department');}public static DimensionAttribute getDimensionAttributeInterCompany(){return FinancialDimensionHelper_[YourPostFix]::getDimensionAttribute('InterCompany', 'InterCompany');}public static DimensionAttribute getDimensionAttributeInterProject(){return FinancialDimensionHelper_[YourPostFix]::getDimensionAttribute('Project', 'Project');}public static DimensionAttribute getDimensionAttributeRevenueStream(){return FinancialDimensionHelper_[YourPostFix]::getDimensionAttribute('RevenueStream', 'RevenueStream');}private static DimensionAttribute getDimensionAttribute(Name _name, Name _localizedName){DimensionAttribute dimensionAttribute = DimensionAttribute::findByName(_name);if (!dimensionAttribute){dimensionAttribute = DimensionAttribute::findByLocalizedName(_localizedName);}return dimensionAttribute;}}
2. Create a new View with methods
Name: DimensionSetView_[YourPostfix]
Methods:
One method for each financial attribute. At my customer they have these:
Code:
public class DimensoinSetView_PostFix extends common
{
private static str getBusinessUnit()
{
return FinancialDimensionHelper_PostFix::getDimensionAttributeBusinessUnit().DimensionValueColumnName;
}private static str getCountry()
{
return FinancialDimensionHelper_PostFix::getDimensionAttributeCountry().DimensionValueColumnName;
}private static str getDepartment()
{
return FinancialDimensionHelper_PostFix::getDimensionAttributeDepartment().DimensionValueColumnName;
}private static str getInterCompany()
{
return FinancialDimensionHelper_PostFix::getDimensionAttributeInterCompany().DimensionValueColumnName;
}private static str getProject()
{
return FinancialDimensionHelper_PostFix::getDimensionAttributeInterProject().DimensionValueColumnName;
}private static str getRevenueStream()
{
return FinancialDimensionHelper_PostFix::getDimensionAttributeRevenueStream().DimensionValueColumnName;
}
}
3. Create the view design
Name: DimensionSetView_[YourPostFix]
Data sources:
- DimensionAttributeValueSet
Fields:
Create one computed string for every financial dimension you have, choose the correct method for the field.
Here I have BusinessUnit example, method from view.
4. Add to a form
A: In for example ProjTransEmpl form you add the view as a datasource in the extension of the form
Name: DimensionSetView_[YourPrefix]
B: Create a extension of the form datasource you just added:
[ExtensionOf(formDataSourceStr(ProjTransEmpl, DimensoinSetView_YourPostfix))]
internal final class ProjTransEmpl_FormDataSource_DimensoinSetView_YourPostfix_Extension
{
public void init()
{
QueryBuildDataSource qbds, qbds1;
next init();qbds = this.query().datasourcetable(tablenum(DimensoinSetView_YourPrefix));
qbds.joinMode(JoinMode::OuterJoin);
qbds.addLink(fieldNum(DimensoinSetView_YourPostFix, RecId1), fieldNum(ProjEmplTrans, DefaultDimension));
}
}
IF you want the new fields to display for everybody add them in the extension of the form or you can add them by personalizing the form from your browser.
In my instance it looks like this and the fields are filterable:
Comments
Post a Comment