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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to pass value to the ER report using query to filter the records from x++ code

(0) ShareShare
ReportReport
Posted on by 470
Hi All,
I have a requirement to call an ER report, read the generated XML, and then create another XML in a different format from it.
We are currently stuck on passing parameter values to the report because the report parameters are designed based on a query.

Could you please advise if there is a way to retrieve that query and pass the values accordingly? 

we have tried by creating contract and adding that contract in the model design but that is not working.

Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,638 Most Valuable Professional on at
    How to pass value to the ER report using query to filter the records from x++ code
    You can pass parameters to ER from code. Let me give you two examples from the standard application:
     
    Using a query:
    ERIModelDefinitionParamsUIAction parameters = new ERModelDefinitionDatabaseContext().addQuery(tablenum(PayrollPositivePayExportEntity), _query);
    Filename filename = strFmt('%1-%2', bankPositivePayTable.PayFormat, bankPositivePayTable.PositivePayNum);
    str outputFileName = ERObjectsFactory::createFormatMappingRunByFormatMappingId(_eRFormatMappingId, filename)
            .withParameter(parameters)
            .run();
    A temporary table buffer and a contract object:
    ERIModelDefinitionParamsAction parameters = new ERModelDefinitionParamsUIActionComposite()
        .add(new ERModelDefinitionDatabaseContext().addTemporaryTable(assetBookCompareTmp))
        .add(new ERModelDefinitionObjectParameterAction(ERModelDataSourceName, 'AssetBookCompareParameters', _contract, true));
    
    // Call ER to generate the report.
    ERObjectsFactory::createFormatMappingRunByFormatMappingId(formatMappingId, DefaultExportedFileName)
        .withParameter(parameters)
        .withFileDestination(_contract.getFileDestination())
        .run();

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 758 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 402 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans