Pages

Tuesday, August 12, 2014

How to get/set printer settings in AX 2012 for SRS reports

This is a simple job that shows you how to get/set printer settings in AX 2012.  In AX 2009, I used things like PrintJobSettings and SysPrintForm where in AX 2012 you use SRSPrintDestinationSettings which uses SysOperationsTemplateForm.

This is just a "Hello World" if you will for modifying the print settings in AX 2012 and I'll be posting a follow up with a slightly more advanced example.


static void GetPrinterSettingsAX2012Simple(Args _args)
{
    SRSPrintDestinationSettings             printSettings = new SRSPrintDestinationSettings();
    SRSPrintDestinationSettingsContainer    printerNameDestination;
    
    // This sets what the user will see defaulted
    printSettings.printMediumType(SRSPrintMediumType::Printer);
    
    if (SrsReportRunUtil::showSettingsDialog(printSettings))
    {
        printerNameDestination = SrsReportRunUtil::getPrinterNameDestination(printSettings);
        
        if (printerNameDestination != conNull())
        {
            info(strFmt("Printer Name: %1", conPeek(printerNameDestination, 1))); 
            info(strFmt("Printer Destination: %1", conPeek(printerNameDestination, 2)));
        }
    }
    else
        info("User clicked cancel");
}

No comments:

Post a Comment