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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

D365FO – SSRS Report prints all records, how to print only selected single record?

(0) ShareShare
ReportReport
Posted on by 24

Hi Experts,

I am customizing a standard SSRS report in D365FO by extending LedgerJournalController.

Current behavior:

  • If no record is selected → report prints all records (standard behavior)

Requirement:

  • If a user selects a single record → report should print only that selected record

  • If no record is selected → report should print all records (standard behavior)

I am not using multi-select (MenuItem property MultiSelect = No).

Below is my controller code:

class LedgerJournalController extends LedgerJournalController
{
    public static LedgerJournalController construct()
    {
        return new LedgerJournalController();
    }
    public static void main(Args _args)
    {
        LedgerJournalController controller   = LedgerJournalController::construct();
        controller.parmArgs(_args); 
        MainAccount tpo_MainAccount;
        if(DevelopmentParameters::find().MainAccBlockingInGL)
        {
            while select * from MainAccount where MainAccount.MainAccount == "1913"
            {
                if(MainAccount.UserId != curExt())
                {
                    controller.parmReportName(ssrsReportStr(LedgerJournal, ReportNew));
                    controller.setRange(_args, controller.parmReportContract().parmQueryContracts().lookup(controller.getFirstQueryContractKey()));
                    controller.parmShowDialog(true);
                    controller.startOperation();
                }
                else
                {
                    controller.parmReportName(ssrsReportStr(LedgerJournal, Report));
                    controller.setRange(_args, controller.parmReportContract().parmQueryContracts().lookup(controller.getFirstQueryContractKey()));
                    controller.parmShowDialog(true);
                    controller.startOperation();
                }
            }
        }
        else
        {
            controller.parmReportName(ssrsReportStr(LedgerJournal, Report));
            controller.setRange(_args, controller.parmReportContract().parmQueryContracts().lookup(controller.getFirstQueryContractKey()));
            controller.parmShowDialog(true);
            controller.startOperation();
        }
    }
//this is my custom code
    public void prePromptModifyContract()
    {
        super();
        Args _args = this.parmArgs();
        if (_args && _args.record() && _args.record().TableId == tableNum(LedgerJournalTable))
        {
            LedgerJournalTable journalTable = _args.record();
            Query query = this.getFirstQuery();
            QueryBuildDataSource qbds = query.dataSourceTable(tableNum(LedgerJournalTable));
            qbds.addRange(fieldNum(LedgerJournalTable, RecId))
            .value(queryValue(journalTable.RecId));
        }
    }
}
 

I tried using _args.record() and applying a filter on LedgerJournalTable.RecId using QueryBuildDataSource, but the report still returns all records.

It seems that setRange() is not respecting the selected record from the form.

 

What is the correct way to pass the selected record from the form to the SSRS report query when using LedgerJournalController?

Should the filtering:

  1. Be applied in the controller by modifying the query before calling setRange()?
  2. Or be handled in the Data Provider (DP) class using a contract parameter?

Also, is setRange() sufficient for handling selected records, or do I need to override the query differently?

Additional Info:

 

  • Menu item: MultiSelect = No
  • Report works correctly for full dataset
  • Requirement is only single record selection
Categories:
I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 163

#2
ManoVerse Profile Picture

ManoVerse 68 Super User 2026 Season 1

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 67 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans