Open custom SSRS report Designs/Formats for reports that use controller classes and managed by print management in Ax2012 R2

Hi all,

Today will talk about, how we can open custom designs of ssrs reports  that uses  controller classes and are managed by Print management. I will also brief about  runPrintMgmt  method , often found in controller classes of a SSRS reports .

runPrintMgmt method executes the report by using print management functionality. often it is seen that controller classes in AOT, override this method to provide print management-related logic and It then invokes any necessary business logic and calls the outputReports method.

Out of the box we see a functionality to view the original or copy of the posted reports  from the journals one such example can be found at  Project management & accounting -> Common-> Project invoices -> Project invoice journals -> button View,   in  Microsoft dynamics Ax 2012 R2 , there are many example of such.

Recently, i was working on a requirement , where in i had to show a copy of the posted report , from a journal, and the report in question was a standard AX report which was using controller classes and had a  new custom design(i.e a new report format that is specific to the customer needs). After a quiet bit of investigation , i realized that controller class always looks into  \Classes\PrintMgmtDocType\getDefaultReportFormat to pick up the format(called from this.parmReportName statement usually) , or it picks up the format from PrintManagementReport format table, where the field System is set to true , for that particular print management document type( usually called from Load settings method of formletter class) . In either cases, it was not picking the format/design, i intend to show.

To achieve this objective i wrote a small piece of code that picks up the custom format/design and this code is called from the method runPrintMgmt , in the controller class, below is the sample code:

private void PrintJobSettings(FormLetterReport  _formLetterReport)
{
boolean                     useUserDefinedDestinations;
PrintMgmtPrintSettingDetail printSettingDetail = new PrintMgmtPrintSettingDetail();
PrintMgmtReportFormat       printMgmtReportFormat;

//In the below statement , i pass the custom format/design, to be picked     You can also use switch statement to pass different formats, if you have 2 or more custom formats/designs.
   printSettingDetail.parmReportFormatName(ssrsReportStr(ReportName, Format));
printSettingDetail.parmType(printCopyOriginal == PrintCopyOriginal::Original ?      PrintMgmtDocInstanceType::Original  :   PrintMgmtDocInstanceType::Copy);
printSettingDetail.parmInstanceName(enum2str(PrintMgmtDocInstanceType::Original));
// Since this will be reported to the screen, one copy is the only thing that makes sense
printSettingDetail.parmNumberOfCopies(1);
printSettingDetail.parmPrintJobSettings(_formLetterReport.parmReportRun().parmDefaultOriginalPrintJobSettings());
if (!_formLetterReport.parmUseUserDefinedDestinations())
{
printSettingDetail.parmPrintJobSettings().printMediumType(SRSPrintMediumType::Screen);
}
_formLetterReport.parmReportRun().loadSettingDetail(printSettingDetail, ”);
}

To conclude, its quiet tricky to open custom formats/design for reports based on controller classes and  also which are manage by print management(Ex:Sales order confimation report). Some times i use post event handler methods to achieve it,like for instance ,fire the post event handler method after the execution of the method \Classes\PrintMgmtDocType\getDefaultReportFormat, and ask the method associated with post event handler to pick up your custom format.Also, if your report is not managed by print management , you can pass the custom format/design as a parameter to the parm method “this.paramReportname(ssrsReportStr(ReportName, Format)); “. 

Thanks

Pradeep.SI

 

1 Comment

Filed under Uncategorized

One response to “Open custom SSRS report Designs/Formats for reports that use controller classes and managed by print management in Ax2012 R2

  1. Hi Pradeep,
    I have encountered the same issue for sales order confirmation report.
    I am having two custom reports with the same document type 2 and i want that reports to be called based on the conditional setting. I am able to achieve it when opening the reports through print management but when opening the reports through original or copy, the report format which is having system set to 1 is getting called. But we don’t need that format. Can you please help me on this.

Leave a comment