/// <summary> /// Prints sales invoice to a PDF file /// </summary> class VKSalesInvoiceAutoPrintBatch extends RunBaseBatch { CustInvoiceJour custInvoiceJour; RefRecId custInvoiceJourRecId; #define.CurrentVersion(1) #localmacro.CurrentList custInvoiceJourRecId #endmacro public container pack() { return [#CurrentVersion, #CurrentList]; } public boolean unpack(container packedClass) { Version version = RunBase::getVersion(packedClass); switch (version) { case #CurrentVersion: [version, #CurrentList] = packedClass; break; default: return false; } return true; } public static VKSalesInvoiceAutoPrintBatch construct() { return new VKSalesInvoiceAutoPrintBatch(); } /// <summary> /// Class description /// </summary> /// <returns>Class description</returns> public client server static ClassDescription description() { return "SalesInvoiceAutomatedBatchPrint"; } public ClassDescription caption() { return "SalesInvoiceAutomatedBatchPrint"; } public boolean mustGoBatch() { return true; } protected boolean canRunInNewSession() { return true; } public boolean canGoBatchJournal() { return true; } public boolean runsImpersonated() { return true; } public boolean showDialog() { return false; } private RefRecId parmCustInvoiceJourRecId(RefRecId _custInvoiceJourRecId = custInvoiceJourRecId) { custInvoiceJourRecId = _custInvoiceJourRecId; return custInvoiceJourRecId; } public void run() { custInvoiceJour = CustInvoiceJour::findRecId(this.parmCustInvoiceJourRecId()); if (custInvoiceJour) { // Do something } info("@SYS335180"); } public static void main(Args _args) { VKSalesInvoiceAutoPrintBatch batch = VKSalesInvoiceAutoPrintBatch::construct(); CustInvoiceJour custInvoiceJour; if (!_args || !_args.record()) { return; } if (_args.record().TableId == tableNum(CustInvoiceJour)) { custInvoiceJour = _args.record(); batch.parmCustInvoiceJourRecId(custInvoiceJour.RecId); } else { return; } batch.batchInfo().parmBatchExecute(NoYes::Yes); batch.prompt(); //run is not needed after prompt, as it will always run in batch, and run will be called from batch framework //batch.run(); } }
VKSalesInvoiceAutoPrintBatch::main();
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.
Authors are allowed to set their own AdSense units and "buy me a coffee" link.
Join us.