Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How to pass query filter in Electronic reporting from source code

(0) ShareShare
ReportReport
Posted on by 71

I have created a custom Export format for bank integration. I need to call ER report from the code and pass the query filter before calling run method. I don't have user input parameters since I am using a query to filter records.

I am stuck on the code on how to pass the value before calling the run method. I have followed this document to pass the value but it is not working coz I don't have a user input parameter and gets into an exception.

This is what I am passing 

pastedimage1678961419971v1.png

When i run the report from ER

 pastedimage1678961534231v2.png

This is where the system throws exception

pastedimage1678961692840v3.png

  • Hammad Khan Profile Picture
    Hammad Khan 71 on at
    RE: How to pass query filter in Electronic reporting from source code

    Hi Arcadi Burria,

    Thanks for the reply. Your comment partially answered my query so I am marking it as an answer

    For those who are facing a similar situation, this is what I did to make it work


    • First, edit and disable ask for query on data source 
      pastedimage1679566813213v2.png
    • Add a user input parameter  JournalNum in my case
    • Add the calculated field and in the formula, section add the filter function and link to a user input parameter 
      pastedimage1679566991547v3.png
    • As mentioned by Arcadi Add the string type field in the data model and bind it to your user input parameter
      pastedimage1679567137952v4.png
    • In code pass your parameter as Model/journalNum  
         const str   erParmJournalNum    = "Model/JournalNum;
                  str         todayDate           = date2str(today(), 123, DateDay::Digits2,DateSeparator::None,DateMonth::Digits2,DateSeparator::None,DateYear::Digits4);
                  FileName    downloadfileName    = "your download file name";
                  ERIFormatMappingRun             ERIFormatMappingRun;
      
                  // Add the input parameter – journal num so that it export the lines only for that journal
                  ERModelDefinitionInputParametersAction modelDefinitionInputParametersAction = new ERModelDefinitionInputParametersAction();
                  modelDefinitionInputParametersAction.addParameter(erParmJournalNum, _journalNum);
                  
                  // attach the file to attachments in journal header
                  Var fileDestination = ERObjectsFactory::createFileDestinationAttachmentWithOtherDocuType("table that your want your attachemnt to attach to");
                  // Export the data in the file based on the input parameters
                  ERIFormatMappingRun = ERObjectsFactory::createFormatMappingRunByFormatMappingId(your format recid, downloadfileName);
                  ERIFormatMappingRun.withParameter(modelDefinitionInputParametersAction);
                  ERIFormatMappingRun.parmShowPromptDialog(false);
                  ERIFormatMappingRun.withFileDestination(fileDestination);
                  ERIFormatMappingRun.run();
              
  • Verified answer
    Arcadi  Profile Picture
    Arcadi 786 on at
    RE: How to pass query filter in Electronic reporting from source code

    Hi Hammad, add your user input of type sstring in the root of your model mapping (center column", call it "XYZ" and pass it in code as "model/XYZ"

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans