Tuesday 26 September 2017

Customizing App Suite reports using extensions

https://blogs.msdn.microsoft.com/dynamicsaxbi/2017/01/02/customizing-app-suite-reports-using-extensions/


Microsoft Dynamics 365 for Operations now offers an expanded set of tools to support custom solutions. Customizations to reporting solutions in the standard application are fully supported using a pure ‘Extension’ model.  This article offers guidance on how to add the most common customizations to standard application reports without over-layering Application Suite artifacts.  Here are some of the key benefits in using an ‘Extension’ based approach when customizing the application
  • Reduces the footprint of your application solutions by minimizing code duplication
  • Custom reports benefit from enhancements made to standard solutions including updates to business logic in Report Data Provider (RDP), data contracts, and UI Builder classes
  • Standard application solutions are unaffected and continue to be available in concert with custom reports
Microsoft Dynamics 365 for Operations (Platform Update3)
______________________________________________________________________________
Report extensions do NOT break or prevent access to standard application reports.  Instead, the platform supports run-time selection of the target report allowing you to choose the appropriate report design based on the context of the user session.  For more information on customizations using extensions, Customization: Overlayering and extensions
SCENARIOS - There are four key scenarios that we’ll focus on which demonstrate the flexibility available in Platform Update3. The first two scenarios involve extending existing RDP classes for our custom reporting solutions. The others offer insights on how to use extensions to redirect application navigations to your custom solutions.
  1. Expanding existing datasets - use table extensions and integrate custom business logic to add custom columns to an existing dataset
  2. Composing custom datasets - add more data to application reports by extending an existing RDP class to return a custom dataset
  3. Extending report menu items - customize application menu items to redirect references to a custom report design
  4. Custom designs for business documents - delegate handlers allow you to add custom report designs to an existing Print Management document instance
Use the following techniques to create custom reporting solutions for the application without over-layering any of the Application Suite objects.

Expanding datasets returned from standard RDP classes

REQUIREMENT
Application report needs more data in
an existing section of a report or visualization.
PROCEDURE
  • Add table extension
  • Add columns to store the data
  • Supply logic to populate the new columns
  • Create custom design
  • Extend report menu items
  • - OR -
  • Extend report controllers
Click here to learn more
extendingdatasets

Extending standard RDP classes to return custom datasets

REQUIREMENT
Use this approach to introduce new data
regions to existing Application reports.
PROCEDURE
  • Create new TMP table
  • Add columns to store the data
  • Extend the RDP class to populate the data
  • Create custom design
  • Extend report menu items
  • - OR -
  • Extend report controllers
customdataset

Redirect application menu item to custom report design

REQUIREMENT
Menu Item extensions allow you to redirect
navigations in the application to custom
reporting solutions
PROCEDURE
  • Create custom report
  • Extend report menu items
  • Add reference to the custom report
Click here to learn more
extendingmenuitem

Adding custom report designs for business documents

REQUIREMENT
This solution is appropriate for making
custom report designs available for business
documents backed by Print Management.
PROCEDURE
  • Create custom report
  • Register delegate handler
  • Add logic to override Print Management Settings
Click here to learn more
extendingprintmgt



Thursday 14 September 2017

Disable financial dimensions in AX 2012 through code

Disabling particular financial dimension based on record or on particular form quite tricky in AX 2012.
Here is an example to achieve disabling Business unit financial dimension on Customers form in AX 2012.
Process to disable Business Unit financial dimension on Customers form.
1. Create a new parm method in ‘DimensionDefaultingControllerBase’ class as shown below
1
2
3
4
void parmEditableDimensionAttributeSetId(RefRecId _editableDimensionAttributeSetId  = editableDimensionAttributeSetId)
{
    editableDimensionAttributeSetId = _editableDimensionAttributeSetId;
}
2. Create a new method in ‘CustTable’ form as shown below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
private void setDimensionAttributeSetStorage()
{
    DimensionAttribute              dimAttr;
    DimensionAttributeSetItem       dimAttrSetItem;
    DimensionEnumeration            dimensionSetId =  DimensionCache::getDimensionAttributeSetForLedger();
    DimensionAttributeSetStorage    dimensionAttributeSetStorage;
    ;
 
    dimensionAttributeSetStorage = new DimensionAttributeSetStorage();
 
    while select * from dimAttr
            order by Name
            where dimAttr.Type != DimensionAttributeType::MainAccount
        join RecId from dimAttrSetItem
            where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
                dimAttrSetItem.DimensionAttributeSet == dimensionSetId
    {
        if (dimAttr.Name != 'BusinessUnit') // Except BusinessUnit rest should enable
            dimensionAttributeSetStorage.addItem(dimAttr.RecId, dimAttr.HashKey,NoYes::Yes);
    }
 
      dimensionDefaultingController.parmEditableDimensionAttributeSetId(dimensionAttributeSetStorage.save());
}
3. Add below highlighted code in ‘init’ method of ‘CustTable’ form as shown below
Calling newly created method before dimensionDefaultingController.pageActivated();
1
2
3
4
5
6
dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(true, true, true, 0, this, tabFinancialDimensions, "@SYS138487");
    dimensionDefaultingController.parmAttributeValueSetDataSource(custTable_ds, fieldStr(CustTable, DefaultDimension));
    // Added by Shankar on 25/11/2013 DisableFinDimensions - Begin
    this.setDimensionAttributeSetStorage();
    // Added by Shankar on 25/11/2013 DisableFinDimensions - End
    dimensionDefaultingController.pageActivated();
4. Now open Customers form & check financial dimensions tab it shows as below.
Can see Business Unit financial dimension disabled, highlighted one.
download