RSS

Reports and Data Methods

06 Oct

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

image

  • 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

image

  • In Solution Explorer, right-click the business logic project and then click Add Reference

image

  • Go to “Projects” tab and select “SRSDrillThroughCommon” and click Ok

image

  • Double click the data method this opens the Code editor
  • Add this line of code the declaration

using Microsoft.Dynamics.AX.Application.Reports;

 

  • Your code editor should be like this

using System;

using System.Collections.Generic;

using System.Security.Permissions;

using System.Data;

using Microsoft.Dynamics.Framework.Reports;

using Microsoft.Dynamics.AX.Application.Reports;

 

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

image

  • 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

image

  • 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

image

  • Click on the link and the customer form opens up

image

About these ads
 
8 Comments

Posted by on October 6, 2012 in AX 2012

 

Tags: , , ,

8 responses to “Reports and Data Methods

  1. Raghu

    October 17, 2012 at 5:52 PM

    Hi Summit after adding data method under ACTION——GO TO URL, when i am trying to open report its showing WARNING:URLs in report may only use http://,https://, help me out to resolve this issue

     
    • Sumit Loya

      October 17, 2012 at 5:56 PM

      For what entity are you trying to hyperlink? Is it customers?

       
      • Raghu

        October 18, 2012 at 10:43 AM

        Yes sumit for customer only,in my data method i am returning
        return DrillthroughHelper.GenerateLinkToAXMenuItem(reportContext, “CustTable”, Microsoft.Dynamics.Framework.Reports.MenuItemType.Display);
        And in action—GO TO URL–expression is =”DataMethod1(Parameters!AX_ReportContext.Value,Fields!AccountNum.Value)” given
        WARNING:URLs in report may only use http://,https://, help me out to resolve this issue

         
      • Sumit Loya

        October 18, 2012 at 11:11 AM

        First of all let me check this method. But if you wish to connect to Customers form, try using

        return DrillThroughCommonHelper.ToCustomerForm(reportContext, custAccount);

         
  2. Anuj

    November 7, 2012 at 9:57 AM

    Hi Sumit,

    In the above blog, the statement “Right click on the Data Methods node and create a new DataMethod. Name it CustDrillDown” and then in the next step “You will also notice that a Business Logic Project is automatically added”. But I have tried these both steps and the Business Logic project will not be automatically added. once we double click on the “CustDrillDown” method, then only it will get added in the solution.

    Regards
    Anuj

     
    • Sumit Loya

      November 7, 2012 at 10:05 AM

      Yes it is added when you double click on the method and go to Code Behind.

       
  3. iampankajlive

    May 28, 2014 at 4:18 PM

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 193 other followers

%d bloggers like this: