In this post, I will explain how to use data methods in Reports. We will use the same Report model and report that we created in Building a Simple Report–Precision Design.
In AX 2009, AX SSRS had good use of these data methods. But with much better integration, and Reporting framework in AX improving, Data Methods in AX SSRS are reduced to minimal use.
Also the reason is that MS is soon going to do away with .Net Business Connector from next version hence the usage of data methods for many things will be redundant. What I have also noticed is the data methods have return type only as System.String and you will not be able to change this return type. This means, data methods can only return strings.
What I will try and demonstrate here is how to add links in AX reports (to open the corresponding forms).
To achieve this first we will add the reference to SRSDrillThroughCommon project. Do the following:
- Open the SKL_SampleReportProject (refer to link above)
- In Application Explorer, right-click Visual Studio Projects > C Sharp Projects > SRSDrillThroughCommon and then click Edit. This adds the SRSDrillThroughCommon project to our current solution
- Open the report SKL_SampleReportPrecision project
- Right click on the Data Methods node and create a new DataMethod. Name it CustDrillDown
- You will also notice that a Business Logic Project is automatically added
- In Solution Explorer, right-click the business logic project and then click Add Reference
- Go to “Projects” tab and select “SRSDrillThroughCommon” and click Ok
- Double click the data method this opens the Code editor
- Add this line of code the declaration
- Your code editor should be like this
public partial class SKL_SampleReportPrecision
[DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
public static string CustDrillDown(string reportContext, string custAccount)
return DrillThroughCommonHelper.ToCustomerForm(reportContext, custAccount);
- Right click on Precision Design and open the designer
- Select the AccountNum text box, underline the text and set font color to Blue
- Now right click on this text box and select “Text Box Properties…”, Switch to Tab “Action”
- Select option “Go to URL” and click button “fx”
- Set Expression “=CustDrillDown(Parameters!AX_ReportContext.Value, Fields!AccountNum.Value)”
- Click Ok
- Save report, go to AX, deploy the report and run it. You should see following
- Click on the link and the customer form opens up