Get list of printers in Dynamics AX 2012 for SSRS reports [Using X++]

Friends,

Below code snippet will help to get the list of available printers in AX 2012.

static void SR_AvailablePrinters_SSRS(Args _args)

{

    Microsoft.Dynamics.AX.Framework.Reporting.Shared.PrinterHelper printerHelper;

    System.Collections.ArrayList names;

    System.Collections.IEnumerator enumerator;

    str name;

    // BP Deviation documented

    printerHelper = new Microsoft.Dynamics.AX.Framework.Reporting.Shared.PrinterHelper();

    names = printerHelper.get_PrinterNames();

    if (names != null)

    {

        enumerator = names.GetEnumerator();

        while (enumerator.MoveNext())

        {

            name = enumerator.get_Current();

            info(name);

        }

    }

}

However, the code which we have learnt to get the list of printers in AX 5.0 will still give the same results in AX 2012.

Just wanted to show another way of getting the printers information in AX 2012 for SSRS printer destinations.

static void SR_2009AXPrinters(Args _args)

{

    PrintJobSettings pjs;

    SysPrintOptions options = new SysPrintOptions();

    int i;

    str printerName;

    ;

 

    pjs = new PrintJobSettings();

       

    for (i = 1 ; i <= pjs.getNumberOfPrinters() ; i++)

    {

        printerName = pjs.getPrinter(i);

        pjs.deviceName(printerName);

        info(printerName);

    }

}

Happy Dax6ng,

sree

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: