Changing design at runtime for the ssrs reports.
For print management reports.
There are reports which are handled by print management while printing.
Even if you create a new design and set it up by modifying "main()" method in controller class it will not reflect.
For this scenario i am taking example of "PurchPurchaseOrder" report which is printed while confirming the PO.
The scenario targets to achieve a functionality where we can call same report, different design called by different menu items.
Here there are two designs one is "kiGalvanizeReport" and other is "kiReport".
To achieve this we need to modify "output()" method of controller class.
Its better to write a new method with parameters and then call the method in the "output()" method.
Below is the code for new method.
private void kiPrintJobSettings(FormLetterReport _formLetterReport,args _args)
{
PrintMgmtPrintSettingDetail printSettingDetail = new PrintMgmtPrintSettingDetail();
if(_args.menuItemName() == menuitemOutputStr(kiPurchPurchaseOrderGalvanize))
{
printSettingDetail.parmReportFormatName(ssrsReportStr(PurchPurchaseOrder, kiGalvanizeReport)); //This is the important line
}
else if (_args.menuItemName() == menuitemOutputStr(DTC_PurchPurchaseOrderOriginal))
{
printSettingDetail.parmReportFormatName(ssrsReportStr(PurchPurchaseOrder, kiReport)); //This is the important line
}
printSettingDetail.parmType(PrintMgmtDocInstanceType::Original);
printSettingDetail.parmInstanceName(enum2str(PrintMgmtDocInstanceType::Original));
printSettingDetail.parmNumberOfCopies(1);
printSettingDetail.parmPrintJobSettings(_formLetterReport.parmReportRun().parmDefaultOriginalPrintJobSettings());
if (!_formLetterReport.parmUseUserDefinedDestinations())
{
printSettingDetail.parmPrintJobSettings().printMediumType(SRSPrintMediumType::Screen);
}
_formLetterReport.parmReportRun().loadSettingDetail(printSettingDetail,"");
}
After this we need to call this method in "output()" method.
protected void output()
{
PurchTable purchTable = PurchTable::find(vendPurchOrderJour.PurchId);
formLetterReport.loadPrintSettings(vendPurchOrderJour, purchTable, purchTable.LanguageId);
//Added on date 27/08/2015 by Kirtan,DTC_PurchPurachseOrder - Start
this.dtcPrintJobSettings(formLetterReport,this.parmArgs());
//Added on date 27/08/2015 by Kirtan,DTC_PurchPurachseOrder - End
this.parmReportContract().parmRdlContract().parmLanguageId(purchTable.LanguageId);
super();
}
After this call the report from respective menu items and it will show the desired the report design.
No need to setup print management parameters for documents.
Happy daxing!!!
Comments
Post a Comment