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 AX (Archived)

Pass selected records in a grid to an RDP based Report

(0) ShareShare
ReportReport
Posted on by 3,208 Moderator

Hi, I have SalesTable records in a grid which I want to pass to the RDP class for the report on the click of a button. I am sending these records through Args() along with a couple other values(including date and an enum) to the controller class. How do I send these selected records in Args() from controller to RDP class?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Brandon Wiese Profile Picture
    17,788 on at

    There are different ways to accomplish that.

    One of the easiest in my opinion is to modify the prePromptModifyContract method in the controller, and add the necessary range(s) to the query so that the proper records are selected on the report.  In your case, that might just be a list of RecId's unless your records have something more fundamental in common.

    Here's a code sample of a similar though slightly more complex solution I used for the ProdReport report, where I wanted the report to automatically filter to the "current" production order or orders depending on the calling form, without making the user click the Select button.

    Note that I have different cases of caller record, i.e. ProdTable, ProdParmReportFinished, and ProdRoute (from Current operations).  In the ProdRoute case, I loop through the selected records in the grid and add the ProdId once each time a new one is found, and I use the Set to track which ones have been found and added already to avoid adding the same ProdId twice.  I call this setRanges() method from prePromptModifyContract as shown far below.

    /// <summary>
    /// Sets the report query ranges based on the caller.
    /// </summary>
    /// <param name="_query">
    /// The hold the <c>Query</c> object of the report.
    /// </param>
    public void setRanges(Query _query)
    {
        QueryBuildDataSource        qbds;
        ProdTable                   prodTable;
        ProdParmReportFinished      prodParmReportFinished;
        ProdRoute                   prodRoute;
        FormDataSource              fds;
        Set                         s;
        ;
    
        qbds = _query.dataSourceTable(tablenum(ProdTable));
    
        while (qbds.findRange(fieldNum(ProdTable, ProdId)))
        {
            qbds.clearRange(fieldNum(ProdTable, ProdId));
        }
    
        if (this.parmArgs())
        {
            switch (this.parmArgs().dataset())
            {
                case tableNum(ProdTable):
                    prodTable = this.parmArgs().record();  // typed
                    qbds.addRange(fieldNum(ProdTable, ProdId)).value(prodTable.ProdId);
                    break;
    
                case tableNum(ProdParmReportFinished):
                    prodParmReportFinished = this.parmArgs().record();  // typed
                    qbds.addRange(fieldNum(ProdTable, ProdId)).value(prodParmReportFinished.ProdId);
                    break;
    
                case tableNum(ProdRoute):
                    prodRoute = this.parmArgs().record();  // typed
                    if (prodRoute.isFormDataSource() && prodRoute.dataSource())
                    {
                        s = new Set(Types::String);  // ProdId
                        fds = prodRoute.dataSource();  // guaranteed to exist
                        for (prodRoute = fds.getFirst(fds.anyMarked()); prodRoute; prodRoute = fds.getNext())
                        {
                            if (!s.in(prodRoute.ProdId))  // check if ProdId already exists in set
                            {
                                qbds.addRange(fieldNum(ProdTable, ProdId)).value(prodRoute.ProdId);  // always add new range
                                s.add(prodRoute.ProdId);  // add ProdId to set
                            }
                        }
                    }
                    else
                    {
                        qbds.addRange(fieldNum(ProdTable, ProdId)).value(prodRoute.ProdId);
                    }
                    break;
    
                default:
                    qbds.addRange(fieldNum(ProdTable, ProdId)).value(SysQuery::valueUnlimited());
                    break;
            }
        }
    }
    

    public void prePromptModifyContract()
    {
        this.setRanges(this.getFirstQuery());
    }


    Hope this helps.

  • Community Member Profile Picture
    on at

    You can pass the record of sales table as argument. Here is an example.

    put the following code in the button click method (eg, button is on the sales order list page)

       salesTable = salesTable_ds.cursor();

      _args.record(salesTable);

       controller.parmReportName(ssrsReportStr(Report, Reportdesign));

       controller.parmArgs(_args);

       controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);

       controller.parmShowDialog(false);

       controller.startOperation();

    put the following code in the controller.main() method:

      controller = new Controller();

       salesTable = _args.record() as salesTable;

       controller.parmArgs(_args);

       controller.parmReportName(ssrsReportStr(Report, Reportdesign));

       controller.startoperation();

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    Hi Brandon,

    I forgot to mark the answer as verified.

    I got the idea from your approach and used it in a similar way to resolve my issue back then.

    Thank you!

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 AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans