Let's say that we want to:
1) Generate and attach a Word document from its template,
2) Send it to specific email address at the same time, and
3) Print it to a specific printer at the same time.
Also, it would be great if we could do all of this occasionally in batch. These requirements remind us of Print Management, right?
Actually, you can accomplish all this by using SSRS or Basic reports, since they both have a functionality to attach output files (in Word as output format) to underlying entities.
Still, if you prefer to use Word documents, you have the appropriate Docentric AX APIs at your disposal.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
static void generateAndPrintWordDocumentFromCode(Args _args) { PurchTable purchTable; DocuTemplate docuTemplate; container generatedDocumentContainer; Filename outputFilename; str documentDataSource; DocPrintDestSettingsPrinter printerSettings; // Select the appropriate template. select firstOnly docuTemplate where docuTemplate.PrimaryTable == tableStr(PurchTable); // Select the primary table record. select firstOnly purchTable where purchTable.PurchId == '000002'; // 1) Get the document XML data source. documentDataSource = DocMailMergeManager::generateDocumentRuntimeDS(docuTemplate, purchTable.RecId); // 2) Use this data source to generate Word document from the template to container (binary). generatedDocumentContainer = DocMailMergeManager::generateDocument(docuTemplate, documentDataSource); // 3) Email the generated document to one or more emails. DocEmailMngHelper::sendEmailOnServer('info@docentric.com', // NOTE: Sender email has to be set but it is ignored. // Always is used the account from E-mail parameters. 'Display sender name', 'support@docentric.com', '', '', 'Subject', 'Body', false, eMailPriority::Normal, 'PurchOrder.docx', generatedDocumentContainer); // 4) Attach the generated document. outputFilename = DocMailMergeManager::attachGeneratedDocument(docuTemplate, purchTable, generatedDocumentContainer); // NOTE: Skip this step if not needed. You can also save the generated document to file system // using one of the following helping methods: //DocFileMngHelper::saveFileOnClient(outputDocumentFilename, genDocContentContainer); //DocFileMngHelper::saveFileOnServer(outputDocumentFilename, genDocContentContainer); // 5) Print document. // To do this, we need to call Docentric Server providing the template document, data source // and the selected printer name. printerSettings = DocPrintDestSettingsPrinter::constructWithPrinter('HPDocentric (HP Officejet Pro 8610)'); // NOTE: To get the list of all available printers in a combobox, and this way enable user // to pick one, use the DocReportingHelper::getPrinterMap() method. // Generate and print document. DocMailMergeManager::generateAndPrintDocument(docuTemplate, documentDataSource, printerSettings); } |
Hi,
Just wondering if this program will allow mail merge, we require to print from an excel list, data needs to include, part number, description and a part number bar-code.
Hi,
I’m not sure that I understood your question. This article talks about the Generate from template feature in AX 2012, which means that you need to use AX query as a data source, or data provider class enabled by Docentric. Thus, we have a Word template designed with Docentric designer and the data fetched from AX via a query or a data provider class, which are merged using Docentric engine into a resulting Word document attached to the context record, which was marked when the Generate from template button was clicked.
Please let me know if I answered your question.
Kind regards,
Ana
Mailto hyperlink not working while converting pdf from Word template through docentric. Upgraded to latest Docentric.Documents but nothing resolved.
Hi,
The Hyperlink tagging element should work :). Please contact us at support@docentric.com and we’ll help from there!
Thanks!
Ana