Search code examples
ssrs-2008axaptadynamics-ax-2012

How can I set a report parameter based on the print medium type?


I need to toggle some presentation in my SSRS Report based on the print medium the report will be generated on.

I have to do this for a bunch of reports (SalesInvoice, SalesConfirm, SalesQuotation).

The problem is I can't find an access point where I have access to both things:

  • In the SalesInvoiceJournalPost class I have access to the printmedium but not the SalesInvoiceContract
  • In the SalesInvoiceController class I have access to the SalesInvoiceContract but the printsettings are giving me false values

In SalesInvoiceJournalPost.init I try:

printSettings = SysOperationHelper::base64Decode(chainFormletterContract.parmPrintersettingsFormletter());
printDestinationSettings = new SRSPrintDestinationSettings(printSettings);

if (printDestinationSettings.printMediumType() == SRSPrintMediumType::Email)
{
    // Can't access Report Parameter from here
}

In SalesInvoiceController.main I try:

printDestination = formLetterController.parmReportContract().parmPrintSettings();
salesInvoiceContract = formLetterController.parmReportContract().parmRdpContract() as SalesInvoiceContract;
salesInvoiceContract.paramMyValue(
    // this is always false because printMedium is always Screen
    printDestination.printMediumType() == SRSPrintMediumType::Email
);

Solution

  • Turns out you can get the SRSPrintDestinationSettings from the controller after all with a few degrees of separation. This is SalesInvoiceController.outputReport:

    PrintMgmtPrintSettingDetail printSettingDetail;
    SRSPrintDestinationSettings printDestinationSettings;
    
    printSettingDetail = formLetterReport.getCurrentPrintSetting();
    printDestinationSettings = printSettingDetail.parmPrintJobSettings();
    salesInvoiceContract.paramMyValue(
        printDestinationSettings.printMediumType() == SRSPrintMediumType::Email
    );