Create documents in docx, xlsx (MS Office Word and Excel), odt, ods (LibreOffice and OpenOffice) and pdf format without MS Office or others plugins installed from any module and subpanel using templates.
#1555 - MailMerge Question: Can I generate a document without the UI?
We have successfully used your MailMerge tools for years now and very much like the way it works. We now have a new requirement and was wondering if you can help?
I would like to send scheduled email messages to our clients with an attached document from MailMerge. Ideally, we would generate the document as part of the mail process but I could also generate the document and save it to a record and then send it from the saved field. I have a variety of tools available including Process Manager and custom PHP script.
Do you know of a method that I can generate a PDF or WORD document based on a schedule or event rather than have a user login and use the UI? Is there a standard URL or something I can manipulate to get a document generated? Any ideas on how I might do this with MailMerge?
Best, Peter
6 years ago
Hi Peter,
Sorry, but there is no url that can be called to generate the documents, it would have to be implemented by code.
What you ask can be added as a new functionality in the component, but this has problems implementing it as a general functionality.
That is, you can parameterize a scheduler, you can parameterize which module and with which template the process will be executed, but what is not easy to parameterize is for wich records will be generated that template, and then to which recipients will be sent each of the documents generated.
Send us more details of how this new functionality would be required exactly and we will review it.
Regards
6 years ago
Hello, I was not really thinking of using a scheduler for this. I wanted to write some specific PHP that would generate the PDF. We use process manager that already has the ability to use a series of events or a schedule to launch PHP code for specific records. It is aware of the ID of the record of focus already. As far as I can tell you now use JS to launch the creation of a PDF and I cannot get that to work via php.
I was thinking more along the lines of a system URL that knows what PDF to generate;
Sample from our system today used to open a record..... https://oursystem.com/index.php?module=CVM_PPSi_ClientVendorMaster&action=DetailView&record=86808269-50ce-a1db-d676-5bfe98b02b8a
What if we could add the ID of the template we want and maybe change the action to MailMergePDF - I could then construct that URL in PHP and get PDFs without the UI. Or something like that.
Thoughts?
6 years ago
Hi Peter,
Try something like this :
Where : - 'module' leave as 'DHA_PlantillasDocumentos' - 'action' leave as 'generatedocument' - 'moduloplantilladocumento' is the target module - 'mode' leave as 'selected' - 'uid' is a comma separated list of uids from the target records - 'enPDF' in pdf'? true/false - 'plantilladocumento_id' is the used document template id
Regards
6 years ago
This information will be added to the component readme.txt in the next version
6 years ago
Thank you so much - that works perfectly. It seems so simple now that I can see it working.