static void PackingSlip_Posting(Args _args) { PurchFormLetter purchFormLetter; PurchId purchId; PurchTable purchTable, update_purchTable; PurchParmTable purchParmTable; ParmId parmId; PurchLine purchLine, update_purchLine; PurchParmLine purchParmLine; Num packingSlipId; ; purchId= "00257_049"; packingSlipId= purchId; purchTable=PurchTable::find(purchid); purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip); purchFormLetter.specQty (PurchUpdate::All); purchFormLetter.transDate (systemDateget()); purchFormLetter.initParmDefault(); purchFormLetter.createParmUpdate(); purchFormLetter.createParmTable(purchParmTable,purchTable); purchParmTable.Num = packingSlipId; purchParmTable.ParmJobStatus = ParmJobStatus::Executed; purchParmTable.insert(); while select purchLine where purchLine.PurchId == purchTable.purchId && (purchLine.RemainPurchPhysical > 0) { purchFormLetter.createParmLine(purchLine); } purchFormLetter.proforma (false); purchFormLetter.printFormLetter(true); }
Comments
See method SalesFormLetter.update() for an example of how it should get called.
You can actually try to use this method instead of most of your code (leave the construct)
My blog - http://kashperuk.blogspot.com
MorphX IT in Russian - http://www.lulu.com/content/723888
Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/3714582