AX_Dev
AX_Dev

Reputation: 69

Passing parameters from Form to AOT Query AX 2012

I am currently on AX 2012 R2. I currently have a custom query object in the AOT that I am using to supply data to a custom SSRS report.

In the SalesTable form, I have a custom button on the SalesTable form in which I overridden the clicked method to call out to a custom Output Menu Item, to supply parameters of SalesTable.CustAccount and SalesTable.SalesId.

However, when I select another record on the SalesTable form and click the custom button, the query dialog displays (dialog for selecting exact values) as normal, but the last selected values for my parameters are still intact. I assume due to usage data.

With creating SSRS reports with Queries, is there a way supply the current selected record values from a form to the dialog as parameters, rather than what is held in usage data?

Please advise and thanks in advance

void clicked()
{
    MenuFunction            jobCardReport;
    Args                    args = new Args();
    Query                   query = new Query();
    QueryRun                queryRun;
    QueryBuildDataSource    qbds;
    QueryBuildRange         queryBuildRange;
    SalesTable              salesTableRecord;
    ;

    salesTableRecord = element.args().record();
    qbds = query.addDataSource(tableNum(SalesTable));
    queryBuildRange = qbds.addRange(fieldNum(SalesTable, CustAccount));
    queryBuildRange.value(salesTableRecord.CustAccount);

    queryBuildRange = qbds.addRange(fieldNum(SalesTable, SalesId));
    queryBuildRange.value(salesTableRecord.SalesId);
    queryRun = new QueryRun(query);

    jobCardReport = new MenuFunction(menuitemOutputStr(TestCard), MenuItemType::Output);
    args.parm(strFmt("TestCard_DynamicParameter=%1, %2", salesTableRecord.CustAccount, salesTableRecord.SalesId));
    jobCardReport.run(args);        

    super();
}

The last 3 lines of code allowed me to pass manual selections from the query dialog using the "Select" button. But on subsequent runs, the manual selections remain despite which record is displayed in the SalesTable form.

Upvotes: 0

Views: 9729

Answers (2)

Setiaji
Setiaji

Reputation: 106

I think the best way for your situation is using SrsReportRunController class. Inside the class, there is a method, name : prePromptModifyContract. This method could contain parameter from SalesTable form, pass it to Report Contract class and process the query inside Data Provider class.

Here is some reference :

I hope this explaination and reference could give you different point of view.

Upvotes: 1

Yuriy
Yuriy

Reputation: 84

Could you please provide code example?

I assume that now you work with query(), but in order to get runtime filter values you should use queryRun(). Both are available from datasource.

Upvotes: 0

Related Questions