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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to pass the selected records to SSRS query dialog

(0) ShareShare
ReportReport
Posted on by 319

Hello All,

I have a SSRS report and run need input the query range: journalId to run SSRS report.

now I need that when I selected the Journal record , then the SSRS query range: JournalId can auto show the selected JournalId records.

I try do below, but no work....please help and thanks a lot:

1. controller:

class KS_PriceDiscAdmOSController extends SrsReportRunController
{
}


 

protected void prePromptModifyContract()
{
    
  PriceDiscAdmTable     priceTable;
  KS_PriceDiscAdmOSContract    contract;

  if(this.parmArgs() && this.parmArgs().record())
    {
     contract   = this.parmReportcontract().parmRdpContract() as KS_PriceDiscAdmOSContract;
     priceTable = this.parmArgs().record();
     contract.parmfield(priceTable.JournalNum);
    }
    
}

public static void main(Args _args)
{
    KS_PriceDiscAdmOSController  controller = new KS_PriceDiscAdmOSController();
    PriceDiscAdmTable   priceDiscAdmTable;

    priceDiscAdmTable = _args.record() as PriceDiscAdmTable;

    controller.parmArgs(_args);
    controller.parmReportName(ssrsReportStr(KS_PriceDiscAdmOS, PD2));
    controller.startOperation();
}

2. Contract:

[DataContractAttribute]
public class KS_PriceDiscAdmOSContract
{
    PriceDiscAdmTable   priceTable;
    PriceDiscJournalNum journalNum;
    
}

public PriceDiscJournalNum   parmfield(PriceDiscJournalNum _journalNum = journalNum)
{

    journalNum = priceTable.JournalNum;
    return journalNum;
}

3. button Click

void clicked()
{
    PriceDiscTable  priceTable;
    Args args = new Args();

    args.record(priceTable);
    new MenuFunction(menuitemOutputStr(KS_PriceDiscAdmOS2),MenuItemType::Output).run(args);
    }

4. Output menuItem:

ObjectType: class

Object: KS_PriceDiscAdmOSController

I have the same question (0)
  • ATMA-Jen Profile Picture
    319 on at

    Hello All,

    When I click the ssrs report button

    There is no Error.

    Just show the ssrs report query dialog: but the JournalId range is still empty.....I want it have to auto get my selected records journalId.

    Thank you.

  • ATMA-Jen Profile Picture
    319 on at

    Hello All,

    My SSRS report is not the RDP report.

    My SSRS report is AOT Query had range: JournalNum  + SSRS

    Please help and thanks a lot.

    Br, jen

  • Suggested answer
    Martin Dráb Profile Picture
    239,118 Most Valuable Professional on at

    That the range is still empty shouldn't be any surprise, because you don't have any code doing anything with query ranges.

    Get the query by calling this.getFirstQuery() (in prePromptModifyContract()).

    Then either create a new range or find an existing one and then set its value.

  • ATMA-Jen Profile Picture
    319 on at

    Hello Sir,

    I add the code,still no work.....Please help & thank you.

    Query                         query;
        QueryBuildDataSource          qDS;
        QueryBuildRange               qRange;
        KS_PriceDiscAdmOSContract    contract;
        PriceDiscAdmTrans     priceTrans;
        PriceDiscJournalNum   journalId;
        
        query = this.parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey());
        qDS   = query.dataSourceTable(tableNum(PriceDiscAdmTrans));
        
        
        if(this.parmArgs() && this.parmArgs().record())
        {     
         qDS.clearRanges();
         qDS.addRange(fieldNum(PriceDiscAdmTrans,JournalNum)).value(journalId);
            
         contract   = this.parmReportcontract().parmRdpContract() as KS_PriceDiscAdmOSContract;
         priceTrans = this.parmArgs().record();
         contract.parmfield(JournalId);
        }

  • Martin Dráb Profile Picture
    239,118 Most Valuable Professional on at

    It would help if you provide a bit more details than just "it doesn't work".

    One obvious problem with your code is that you never assign any value to journalId, therefore you effectively don't set any range value.

    By the way, isn't getFirstQuery(), as I suggested, easier to write than parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey())?

  • ATMA-Jen Profile Picture
    319 on at

    Hello Sir,

    Thanks a lot for your reply in first.

    I try, then
    I still no work, I think I can understand how to pass the selected records infomation to SSRS dialog.

    Could you give me a case study or walkthrough, thanks.

    I changed my code, but ssrs dialog JournalNum parameter still empty:
    Journal Form button click:

    void clicked()
    {
    
        PriceDiscAdmTable  priceTable;
        Args args = new Args();
    
        priceTable = PriceDiscAdmTable_ds.cursor();
        args.record(priceTable);
        new MenuFunction(menuitemOutputStr(KS_PriceDiscAdmOS2),MenuItemType::Output).run(args);
    }

    Class - Contract:

    [DataContractAttribute]
    public class KS_PriceDiscAdmOSContract
    {
        PriceDiscAdmTable   priceTable;
        PriceDiscJournalNum journalId;
    
    }

    public PriceDiscJournalNum   parmfield(PriceDiscJournalNum _journalId = journalId)
    {
    
        journalId = priceTable.JournalNum;
        return journalId;
    }

    Class - Controller:

    class KS_PriceDiscAdmOSController extends SrsReportRunController
    {
    }

    protected void prePromptModifyContract()
    {
    
      PriceDiscAdmTrans     priceTrans;
      PriceDiscJournalNum   journalId;
      Query query = this.getFirstQuery();
    SrsReportHelper::addParameterValueRangeToQuery(query,
                                                   tableNum(PriceDiscAdmTable),
                                                   fieldNum(PriceDiscAdmTable, JournalNum),
                                                   journalId);
    
    
    
    }

    public static void main(Args _args)
    {
        KS_PriceDiscAdmOSController  controller = new KS_PriceDiscAdmOSController();
        PriceDiscAdmTable   priceTable;
    
    
        priceTable = _args.record() as PriceDiscAdmTable;
    
        controller.parmArgs(_args);
        controller.parmReportName(ssrsReportStr(KS_PriceDiscAdmOS, PD2));
        controller.parmDialogCaption("aaaaaatest");
    
        controller.startOperation();
    }
    

    public void setRanges(Query _query)
    {
        QueryBuildDataSource        qbds;
        PriceDiscAdmTable           priceTable;
    
        ;
    
        qbds = _query.dataSourceTable(tablenum(PriceDiscAdmTable));
    
        while (qbds.findRange(fieldNum(PriceDiscAdmTable,JournalNum)))
        {
            qbds.clearRange(fieldNum(PriceDiscAdmTable,JournalNum));
        }
    
        if (this.parmArgs())
        {
            
                    priceTable = this.parmArgs().record();  // typed
                    qbds.addRange(fieldNum(PriceDiscAdmTable,JournalNum)).value(priceTable.JournalNum);
                    
    
                
        }
    }

    Please help and Thank you in advance.

  • ATMA-Jen Profile Picture
    319 on at

    Hello Sir,

    by the way,

    1. My ssrs report is about PriceDiscAdmTrans infomation.

    2. The print ssrs button is on PriceDiscAdmTable ActionMenu.

    3. Click the print ssrs button is show the ssrs dialog is PriceDiscAdmTrans.JournalNum

    4. so I in Query data source: PriceDiscAdmTrans add inner  join PriceDiscAdmTable and relation Both Table.JournalNum and set range  PriceDiscAdmTable.JournalNum (Open)

    5. If menuitem for ssrs report: the ssrs dialog show PriceDiscAdmTrans.JournalNum and PriceDiscAdmTable.JournalNum

    6. If click PriceDiscAdmTable Form button(Class-Controller) the ssrs dialog still show PriceDiscAdmTrans.JournalNum, after reset ssrs parameter will show both but two field parameter still empty....

    please help and thank you.

    Br, Jen

  • ATMA-Jen Profile Picture
    319 on at

    Hello Sir,

    I really would like to know and this is very important and I always need this function to print ssrs report.

    If you could

    please perform me a simply case,

    then I think I will understand Ax how to run it.

    Thanks you a lot.

    Br, Jen

  • Suggested answer
    Khushhal Garg Profile Picture
    1,514 on at

    Is it opening report dialog on clicking button? Do you see journal number pre-populated? if not, try to reset usage data.

  • Suggested answer
    Khushhal Garg Profile Picture
    1,514 on at

    Also, if still not works, then try to debug and see if it is going to preprmoptmodify method

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 733

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 278 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans