web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Menu item create for ER

(3) ShareShare
ReportReport
Posted on by 1,275
Hi Everyone,
 
I have created a ER report for customer group export and it is successfully export it in excel. As I am admin, that's why I am able to run it from Organization - Electronic reporting -- Configuration -- Model.
 
But this report will use by the end user. So, I guess I need controller class and new menu item to run the ER report.
 
As I am new to ER, kindly provide me reference for the controller class. I mean how will call the ER report to the controller class.
 
Thanks in advance! 
Categories:
I have the same question (0)
  • CU05031448-0 Profile Picture
    1,275 on at
    Any update on this?
  • Suggested answer
    Jonas "Jones" Melgaard Profile Picture
    4,930 Most Valuable Professional on at
    Hi CU05031448-0,
     
  • CU05031448-0 Profile Picture
    1,275 on at
    Thanks, Jonas for the reply. I go through the link which you provided. What I understood, I need only two classes like Controller and report services to call the ER through menu item.
     
    Because below classes like:
    Contract - required we have parameter in report
    UI Builder - required when we need value in run time in dialog in report
    DP - required when we need to fill data in Temp table and required business logic to manipulate data.
     
    Am I correct?
     
     
  • Jonas "Jones" Melgaard Profile Picture
    4,930 Most Valuable Professional on at
    That is my assumption yes, they don't use the DP class in this example.
    Try to implement this and see if it works for you.
  • CU05031448-0 Profile Picture
    1,275 on at
    Thanks, Jonas for the reply.
     
    Let's do that and will update you soon. thanks!
     
     
     
     
  • CU05031448-0 Profile Picture
    1,275 on at
    Hi Jonas, I tried with the below classes:
     
    Controller class:
    class CustGroupsERController extends ERFormatMappingRunBaseController
    {
        public ClassDescription defaultCaption()
        {
            return "Customer groups report";
        }
    
        public static void main(Args _args)
        {
            CustGroupERController   operation;
    
            operation = new CustGroupERController(classStr(CustGroupERReportService),
                                                      methodStr(CustGroupERReportService, generateReportByGER),
                                                      SysOperationExecutionMode::Synchronous);
            operation.startOperation();
        }
    
    }
    Report Service class:
     
    using Microsoft.Dynamics365.LocalizationFramework;
    
    class CustGroupsERReportService extends SysOperationServiceBase
    {
        public const str ERModelDataSourceName = 'model';
        public const str DefaultExportedFileName = 'Customer groups';
        public const str ParametersDataSourceName = 'RunTimeParameters';
    
        public void generateReportByGER()
        {
            ERFormatMappingId formatMappingId = ERFormatMappingTable::findByName("Cust group format").RecId;
    
            if (formatMappingId)
            {
                try
                {
                    ERIModelDefinitionParamsAction parameters = new ERModelDefinitionParamsUIActionComposite()
                        .add(new ERModelDefinitionObjectParameterAction(ERModelDataSourceName, ParametersDataSourceName, "", true));
                    
                    // Call ER to generate the report.
                    ERIFormatMappingRun formatMappingRun = ERObjectsFactory::createFormatMappingRunByFormatMappingId(formatMappingId, DefaultExportedFileName);
                    formatMappingRun.withParameter(parameters);
                    formatMappingRun.run();
                }
                catch
                {
                    // An error occurred while exporting data.
                    error("@SYP4861341");
                }
            }
            else
            {
                // There is no data available.
                info("@SYS300117");
            }
        }
    
    }
    But I got the below error:
     
     
    Could you please advise me where is my code is wrong and what changes are required to fix the issue.
     
    Thanks in advance.
     
     
     
  • Jonas "Jones" Melgaard Profile Picture
    4,930 Most Valuable Professional on at
    Think I misread your question, sorry.
    You should not have to make the DP class, but the other classes are required. 
     
    From the attached code in your last reply:

    ERIModelDefinitionParamsAction parameters = new ERModelDefinitionParamsUIActionComposite()

    .add(new ERModelDefinitionObjectParameterAction(ERModelDataSourceName, ParametersDataSourceName, "" (This is a class in Microsoft example, and explains why it complains about types), true));

     

     
    Try to implement the contract and UI builder, and see if this helps you.
     
  • CU05031448-0 Profile Picture
    1,275 on at
    Hi Jonas, thanks for your reply and I have tried the below classes as suggested.
     
    Contract
    public class CustGroupsERContract implements SysOperationValidatable
    {
        CustGroupId     custGroup;
        public boolean validate()
        {
            boolean isValid = true;
            return  isValid;
        }
    
        [DataMemberAttribute('CustGroup')]
        public CustGroupId parmCustGroup(CustGroupId _custGroup = custGroup)
        {
            custGroup = _custGroup;
            return custGroup;
        }
    
    }
    Controller
     
    class CustGroupsERController extends ERFormatMappingRunBaseController
    {
        public ClassDescription defaultCaption()
        {
            return "Customer groups report";
        }
    
        public static void main(Args _args)
        {
            CustGroupERController   operation;
    
            CustGroupsERContract contract = new CustGroupsERContract();
    
            contract.parmCustGroup();
    
            CustGroupsERReportService::generateReportByGER(contract);
        }
    
    }
    Report service
     
    using Microsoft.Dynamics365.LocalizationFramework;
    
    class CustGroupsERReportService extends SysOperationServiceBase
    {
        public const str ERModelDataSourceName = 'model';
        public const str DefaultExportedFileName = 'Customer groups';
        public const str ParametersDataSourceName = 'RunTimeParameters';
    
        public static void generateReportByGER(CustGroupsERContract _contract)
        {
            ERFormatMappingId formatMappingId = ERFormatMappingTable::findByName("Cust group format").RecId;
    
            if (formatMappingId)
            {
                try
                {
                    ERIModelDefinitionParamsAction parameters = new ERModelDefinitionParamsUIActionComposite()
                        .add(new ERModelDefinitionObjectParameterAction(ERModelDataSourceName, ParametersDataSourceName, _contract, true));
                    
                    // Call ER to generate the report.
                    ERIFormatMappingRun formatMappingRun = ERObjectsFactory::createFormatMappingRunByFormatMappingId(formatMappingId, DefaultExportedFileName);
                    formatMappingRun.withParameter(parameters);
                    formatMappingRun.run();
                }
                catch
                {
                    // An error occurred while exporting data.
                    error("@SYP4861341");
                }
            }
            else
            {
                // There is no data available.
                info("@SYS300117");
            }
        }
    }
    *** Now when I run the report from UI
     
    Account Receivable -- Report -- 
     
    Note: When we click on the above menu item then I will NOT get any dialog for Customer group and the report will export the data in excel directly.
     
    Organization administration - Electronic reporting -- Configuration
     
     
    When I run the report, I am able to get the dialog to filter the Customer group.
     
     
    Note - The same dialog I also expected from UI level also. When user run the ER form Account Receivable module.
     
    Could you please let me know How will I fix the issue and why it is not displaying the dialog from UI level.
     
    Thanks in advance!
  • CU05031448-0 Profile Picture
    1,275 on at
    Hi Jonas, once available, could you please reply on this. Thanks!
  • André Arnaud de Calavon Profile Picture
    300,917 Super User 2025 Season 2 on at
    Hi,

    You created an inappropriate question on the forum referring to this question. Please update this question to get it on the top of the list and in case persons have subscribed to the question, they will receive notifications. 
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans