Call Query based SSRS using dynamic range

Hello All,

i am currently working on query based SSRS report.

it is generated and now i have one case where on the click of button i want to pass the range value.

there are 3 ranges and i just want to pass one range value.

With which part of the requirement do you need our help?
Also, what’s your version of AX? You didn’t attach any tag with your version…

Hello Martin,

this is ax 2012 R2,

i have one button on form, click on the button will open SSRS report, SSRS report is query based and has many ranges.

now i want to pass one value on the button click to one of the range of AOT query so that report will open with that filteration.

but i am not able to pass the value to query and report is taking the last saved value as range .

I can’t comment on what’s wrong in your code, because I’ve never seen it. You would have to give us more information.
Consider adding the range in preRunModifyContract() method of your controller class.

Thank you Martin for your prompt reply,

i am using query based ssrs report. not using RDP so in my case i can filter giving value to my range which i have specified in the query,

i just want to know how can i give the range value using code and it will open the report considering that range values.

in the below example the only thing i want is to open my report in the last

static void _AOTquery(Args _args)
{
date dateFrom = 01\01\2012 ;
date dateTo = 31\01\2012 ;
CustInvoiceJour custInvoiceJour;
Query query = new Query(queryStr (CustInvoiceJour)); // Query name.
QueryRun qr;
QueryBuildRange qbr;
;

// Find the InvoiceDate range on AOT Query.
qbr = query.dataSourceTable( tablenum (CustInvoiceJour))
.findRange( fieldNum (CustInvoiceJour, InvoiceDate));

// We can check if the query range does exist, if not, we can create it.
if (!qbr)
{
qbr = query.dataSourceTable( tableNum (CustInvoiceJour))
.addRange( fieldNum (CustInvoiceJour, InvoiceDate));
}

// Assigning query range value.
qbr.value(SysQuery::range(dateFrom, dateTo));

// We can also define an Order By through code.
query.dataSourceTable( tableNum (CustInvoiceJour))
.addOrderByField( fieldNum (CustInvoiceJour, OrderAccount));

// Executing our query.
qr = new QueryRun(query);

}

please let me know if i am still not able to give clear idea about my issue, i will try to explain in more details

Your code is just a job creating a query.

I though you wanted to take a value from a form and add it as a range to report. But your code doesn’t do anything like that.

Let’s start from the beginning. I suggest you start with adding a hard-coded range to prePromptModifyContract() or preRunModifyContract() method of your report controller class, without considering values selected in the form. When get it running, you’ll add the logic for setting the value from the form. Look at the following thread for details: SSRS Report calling mechanism from form.

Hello Martin,

i am not using RDP classes for report, i am using direct query.

I know. I’m talking about the controller class, not a data provider class.
All reports can have a controller; it’s unrelated to how they fetch data.

Super Martin,