robsCode
  • Home
  • About
  • Privacy Policy
Subscribe
d365

[D365] Get list of Designs of SRS Report by code

  • Robin Kretzschmar

Robin Kretzschmar

Jul 22, 2020 • 1 min read

Recently the requirement to list all designs of a SRSReport came up and the Metadata API is a good fit for the task to accomplish this with as less lines of code as possible.

The example below will add a static method to the standard class SrsReportHelper to have it available system-wide.

using Microsoft.Dynamics.AX.Metadata.MetaModel;
using System.Collections;

[ExtensionOf(classStr(SrsReportHelper))]
public final class SrsReportHelper_Extension
{
	public static List robsGetDesignsOfReport(SRSReportName _reportName)
    {
        List srsReportDesignsList = new List(Types::String);
        AxReport axReport = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetReport(_reportName);
        // axReport.Designs will return a KeyedObjectCollection. Check it with ildasm.exe
        var designs = axReport.Designs;
        int noOfDesigns = designs.Count;
        for (int dIdx = 0; dIdx < noOfDesigns; dIdx++)
        {
            AxReportDesign design = designs.get_Item(dIdx);
            srsReportDesignsList.addEnd(design.Name);
        }
        
        return srsReportDesignsList;
    }

}

The using statement at the top is only comfort to be able to use the metadata interfaces like AxReport without the whole assembly name.

Usage

An example to consume the method:

TmpSrsReportDesignName tmpSrsReportDesignName;
ListEnumerator le = SrsReportHelper::robsGetDesignsOfReport(reportStr(SalesInvoice)).getEnumerator();

tmpSrsReportDesignName.clear();
tmpSrsReportDesignName.initValue();

while (le.moveNext())
{
    tmpSrsReportDesignName.DesignName = le.current();
    tmpSrsReportDesignName.insert();
}
    

Sign up for more like this.

Enter your email
Subscribe

[D365] Module reference in model cannot be located

Sometimes it happens on a D365 DevBox that after a get latest or some copy operation in the PackagesLocalDirectory folder the following error occurs after using "Refresh models" in Visual Studio: Module Reference 'yyy' in model 'zzz' cannot be located. This is an indication that model store is in a
Nov 4, 2021 — 1 min read

[D365] Check Version without client (files)

Checking the Platform Update Version from the client is easy: Click the questionmark icon in the top right corner and select "About" to see the version info. But what to do if the client is not available (for example because a build is failing)? In earlier versions it was possible
Oct 27, 2021 — 1 min read

[D365] How to update ISV solutions with version control

Often one or more ISV solution can be found in larger projects. Either if they are bought to solve a specific problem in shorter time or to introduce industry specific functionality, they receive frequent updates and the project team or customer needs to deal with them. It makes sense to
Aug 10, 2021 — 1 min read
robsCode © 2023
  • Sign up
Powered by Ghost