Book Image

Microsoft Dynamics AX 2012 R3 Reporting Cookbook Update

Book Image

Microsoft Dynamics AX 2012 R3 Reporting Cookbook Update

Overview of this book

Table of Contents (17 chapters)
Microsoft Dynamics AX 2012 R3 Reporting Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Adding a datasource through business logic


This recipe will show how a simple datasource can be created and used as a source of data through the business logic option in reports.

Getting ready

This recipe requires that you have access to Visual Studio with the Dynamics AX reporting extension.

How to do it...

  1. Create a new reporting project called PktExchRateReports in Visual Studio.

  2. Add a report and name it PKTExchRateDataTable.

  3. Right-click on the Data Method node and create a new method as shown in the following screenshot:

  4. Double click the TestMethod node. This adds a new C# project to the solution and a C# class with the same name as the report.

  5. Replace the empty data method with the business logic shown here:

    [DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
    Public static DataTable ExchangeRateDataset(string _stest)
        {
    DataTable dt;
    // Adding rows and columns in DataTable 
    dt = new DataTable();
    dt.Columns.Add("Category", typeof(string));
    dt.Columns.Add("Base Currency...