AX 2009, AX 2012, Development, Dynamics AX, Uncategorized

How to send a file to the printer in dynamics AX

How to send a file to the printer in dynamics AX

Following Job demonstrates on how to send a file from the file system to the locally connected printer( printer physically can be network or local but it should be added to the client and its name should be visible in the control panel–> devices and printers)

static void sendToPrinter(Args _args)
PrintJobSettings printJobSettings = new PrintJobSettings();
Dialog dialog = new Dialog();
DialogField dialogFileName;
str CoreLabelExe;
str CoreLabelParm;
// initiallize printer with the printer name. This initiallization automatically
// gets dll file details and port details.
printJobSettings = new PrintJobSettings();
printJobSettings.deviceName(‘Microsoft XPS Document Writer’);
dialogFilename = dialog.addField(typeid(FilenameOpen));
if (
// finding executable DLL
CoreLabelExe = WinAPI::findExecutable(dialogFileName.value());
// Create Shell command parameter
CoreLabelParm = strFmt(‘ /PT “%1” “%2” “%3” “%4″‘,
// run dll on the shel with parameter
winAPI::shellExecute(CoreLabelExe, CoreLabelParm);

AX 2012, Development, Dynamics AX, Uncategorized

Reserve quantity by X++ code

Quick code snippet to reserve the quantity by X++

SalesLine locSalesline;

InventMovement inventmovement;

InventUpd_Reservation reservation;

inventMovement = InventMovement::constructNoThrow(locSalesline,InventMovSubType::None);

reservation = InventUpd_Reservation::newinventdim(inventMovement, InventDim::find(InventDimReserveFrom),-1*inventqty, false);