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

How to get parameter from the query

(0) ShareShare
ReportReport
Posted on by 260

Hello guys,

I'm trying to do a job here that opens an existing report through the menu item using the following code

new MenuFunction(menuitemOutputStr(ProdPickListShowDialog), MenuItemType::Output).run();

The report dialog will pop up and the user will use it normally.

pastedimage1565957311383v1.png

I would like to know if that is any way to grab the values from Picking list journal field and Production field after the user press ok and run the report.

This is just a part of the job I need these values to go to the next step.

A parameter that is not from the query is easy to get but these parameters are from the query, I did some search and I didn't see anything related. 

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at
    RE: How to get parameter from the query

    Hi!

    If you want to get what you want, you should use a class instead of menu item and you can get the parameters, query and so on.

    Check the ProdPickListController class.

  • bois0155 Profile Picture
    260 on at
    RE: How to get parameter from the query

    Thanks for the reply.

    Actually, I'm using the class already. I changed

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

    ...

    I can open the report dialog pass values to all parameters but what I really want is get the values from query parameters that user will populate. after the user runs the report.

    I was thinking about using SysLastValue

  • Suggested answer
    Khushhal Garg Profile Picture
    1,514 on at
    RE: How to get parameter from the query

    You should be able to access current query object and datasource in run method. Then use findRange method and value method on findRange to get values passed in the query. Let me know if you are having issues with this approach.

    something like this...

    query.dataSourceTable(tablenum(tablename)).findRange().value()

  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at
    RE: How to get parameter from the query

    If you see report controller prePromptModifyContract method range are applied there and also query object is create there. You can get ranges you want to get from query object. Take a look at this link for a reference.

  • enricoariel Profile Picture
    60 on at
    RE: How to get parameter from the query

    depends how the dialog is made. if you extended SrsReportDataContractUIBuilder then you can override the method preRunModifyContract. here an example:

    protected void preRunModifyContract()
    {
    #define.parameterFromDate('FromDate')
    #define.parameterToDate('ToDate')
    SrsReportRdlDataContract contract =
    this.parmReportContract().parmRdlContract();
    Date fromDate =
    contract.getParameter(#parameterFromDate).
    getValueTyped();
    date toDate =
    contract.getParameter(#parameterToDate).
    getValueTyped();
    Query query = this.getFirstQuery();
    // Modify the query contract based on fromDate & toDate.
    SrsReportHelper::addFromAndToDateRangeToQuery(query,
    fromDate,
    toDate,
    tableNum(CustTrans),
    fieldNum(CustTrans, TransDate));
    }

    you can usein the sysLastValue, look \Classes\xSysLastValue\getLast

    alternatively you can use reflection, something like this (you need to adapt to your needs):

    private void showParameters()
    {
    DictClass dictClass;
    DictMethod dictMethod;
    MethodName methodName;
    int i;
    dictClass = new DictClass(classidget(this));

    if (dictClass.objectMethodCnt())
    setprefix('the test completed');//can be anything

    for (i = 1; i <= dictClass.objectMethodCnt(); i++)
    {
    dictMethod = dictClass.objectMethodObject(i);
    methodName = dictMethod.name();
    setPrefix('Parameters used:');
    if (strStartsWith(methodName, 'parm')) //&& dictMethod.accessSpecifier() == AccessSpecifier::protected)
    infolog.add(Exception::Info, strFmt('%1 - %2: %3',
    dictClass.name(),
    subStr(methodName, 5, 100),
    dictClass.callObject(methodName, this)
    ));
    }

    }

    I hope I gave you the idea...

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans