Recently I have come across a requirement where, I have to print the Bill Of lading(MS dynamics out of box report) automatically based on Packing slip successful posting from sales order.
Below is the code:
- In the IF statement, it first checks the type of object for ‘SalesFormLetter_PackingSlip’ as the salesFormLetter is the base class of many child class, so it checks specific for Packing slip plus it checks for the numberOfOrdersPosted not equal to ‘0’ ,then later I have created a new class ‘MzkPrintBOL’ with static method ‘printBOL’ which takes salesTable for further use’
First it creates a Bill of lading data (WMSBillOfLading table), then I have used to objects(see below)
- PrintJobSettings object, the reason I have used is to get the default installed printer information from the system (i.e. printer name,port name etc.)
- SRSPrintDestinationSetting, I have used the object to get and set the bill Of lading controller printer setting in order to directly print the report instead of showing on the screen.
Finally I called the controller.startOperation(), which actually start the report.
Hope this help!