This post is machine-translated. The original post in german language can be found here.

Call SSRS-Report through code

A common requirement is that a report / report should be printed automatically at a certain point in time.

It is usually important to be able to give certain parameters to the report to be printed, and depending on how the report is structured on the development side this can be more or less complicated.

The following code calls a relatively simple Dataprovider-based report:

TutorialMyReportDataContract dataContract;
SrsReportDataContract srsReportDataContract;

controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(TutorialMyReport, MyDesign)); 
controller.parmShowDialog(false);    
controller.parmLoadFromSysLastValue(false);  

srsReportDataContract =
controller.parmReportContract();

dataContract = srsReportDataContract.parmRdpContract();

dataContract.parmSalesId("S1000"); 

The next example calls the standard report Transactions (Customer Accounts > Reports > Transactions > Customer). The special feature of this report is that it uses a query within the data provider. To access these was the challenge:

CustTransListContract dataContract;
SrsReportDataContract srsReportDataContract;
Map map;
MapEnumerator me;
SysOperationQueryDataContractInfo SysOperationQueryDataContractInfo;
QueryBuildRange queryBuildRange;
QueryBuildDataSource queryBuildDataSource;    
Object dataContractInfoObject;

controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(CustTransList, Report)); 
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);  

srsReportDataContract =
controller.parmReportContract();

dataContract = srsReportDataContract.parmRdpContract();

// Modify parameters
dataContract.parmOnlyOpen(true);  

// Modify query
map = controller.getDataContractInfoObjects();
me = map.getEnumerator();

while(me.moveNext())
{
    dataContractInfoObject = me.currentValue();
     
    if(dataContractInfoObject is SysOperationQueryDataContractInfo)
    {
        SysOperationQueryDataContractInfo = dataContractInfoObject; 

        // Add range
        queryBuildDataSource =
SysQuery::findOrCreateDataSource(SysOperationQueryDataContractInfo.parmQuery(), tableNum(CustTable));

        queryBuildRange = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(CustTable, AccountNum));

        queryBuildRange.value("1001");            
    }
}
These post applies to following version:
Dynamics AX 2012

Add comment

 

 
 
 
posts of the actual month
Januar 2019
MoDiMiDoFrSaSo
 123456
78910111213
14151617181920
21222324252627
28293031 
 
 
© 2006-2019 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.