It’s 2019 and the new year bells have rung many times (as we admittedly get near to even more going into 2020 in a little over 17 weeks) since many posts were created on this topic and, still, Suite CRM has no ability to Email a dynamically generated PDF. Many people have asked (Going back over 5 years) and, it would seem every frustrated user that had hoped for a response from the Developers and others with a solution will have been destined for disappointment. here’s what I found on the topic having gone round and round in circles:
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/1149-attaching-pdf-template-to-e-mail
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discusion-general/21407-how-to-attach-pdf-template-to-email-template
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/12735-email-pdf-template-as-attachment-through-workflow
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/8386-email-pdf-using-logic-hook
https://suitecrm.com/suitecrm/forum/advanced-opensales-workflow-portal-support/12659-email-pdf-template-as-attachment-through-email-workflow
https://suitecrm.com/suitecrm/forum/developer-help/1080-generate-pdf-with-worklflow-module-and-send-it-as-mail-attachment
Aside from noticing that there is a third party extension module in the Suite CRM store, I can’t see how, with repeated need demonstrated over the years, that Suite CRM would not have noticed the requests for dynamically generated PDF to Email functionality and I can only imagine the dismay at the functionality being unexpectedly discovered as not present.
From a usability perspective, I am extremely sympathetic of anyone’s “plug and play” starting approach to Suite CRM - to see what options are available and what populated menus items are available from the get-go as hints in terms of Suite CRM built in functionality before further exploration.
So, in terms of this approach, a new user sees “PDF Templates”. they see “Workflow”, “Cases”, they see “Email” and “Email Templates” and they see that PDF Templates, Emails and cases are available within the workflow module too as options for Workflow rules. Within the PDF Templates option, a new user sees the ability to add in variables for dynamic generation.
So, you’d be forgiven for entering in your data and expecting to be able to get Suite CRM, within its’ GUI, without additional code, to work in terms of dynamically generating PDF’s and attaching them to Emails and to add updates to case records as the result of workflow automation (particularly in terms of development testing to know that each automation stage worked correctly) - after all, if the feature is not intended to work out of the box then what’s the point in even bothering to add it as a menu item in the GUI when custom functionality is routinely added from the drop down editor and through the creation of ad-hoc relationships and the addition of fields through the Suite CRM built in studio and wider admin functionality?
I have had a separate conversation on the forums last week about this approach and, it would seem from Sales Agility (the company behind the maintenance of Suite CRM)'s perspective that people who attempt to use the software out of the box are misguided by simply expecting it to work and that they should expect to have to do custom coding as standard. I will emphasise, it was quite obvious that custom configuration (within the GUI) and custom coding were clearly very different in that thread.
Personally i’m extremely cynical about such core functionality being left out of Suite CRM. The Developers maintain that they have a very small team and that they can’t get around to things straight away. Emailing of dynamic PDF’s as attachments has been a request around for over 5 years and I have seen many other massive and smaller projects completed by the Development team in that time through review on Github. Meanwhile, we see a paid for extension (purported to be a third party extension) for $70 on the Suite CRM store providing functionality for something ignored over 5 years.
As I have said before, there is clearly no point in having a PDF template mechanism if it has to be manually activated on a one time basis, given the amount of manual interaction, any PDFs might as well be virtually printed from any software and attached in your favourite Email client (Outlook, Thunderbird to name a few).
Similarly within Workflow, to demonstrate the scale of the problem, there is not even a way to automate the dynamic generation of a PDF Template for adding to a client record such that an Email could be generated notifying the client of the newly generated PDFs existence (in the absence of emailing the dynamically generated PDF as an Email attachment in the first place). There is also no way of updating a client’s notes through workflow automation either (but there is an ability to create “internal” (private) notes not published to the Joomla plugin portal) - I think this is a bug.
I’m sure you can, by now, see how my project has been a struggle from start to (no)finish. Purported functionality should not be populated in the menu items, it should be grayed out until premium activation, or should work from the get-go. Functionality that is exceptionally limited should be highlighted as so by these means. Not everybody (certainly not I) is a coder but some of us look to Open Source software to do completely free community work (I mean not a penny changes hands and no back door benefits either, not even a chocolate bar!).
I host on a home computer for example. Not all of us are in a position to pay coders exuberant amounts of money for functionality and nor should we be held to ransom, not by misguiding ourselves (as nauseatingly previously insinuated) as to Suite CRM (or SA)'s abilities but by being misled in, what is at best, features rolled out before they are complete, at worst, deliberate mis-advertisement of capabilities by virtue of their population within the GUI so that users get hooked by their time investment and later discover that they are completely stuck. Both fall squarely under the responsibility of Suite SRM Development and not the user.
It’s only fair if I suggest a much more innocent return on behalf of Suite CRM - that they have created populated menu items (such as PDF Templates, Workflows etc) to advertise the capabilities of Suite CRM presuming custom coding development but even this to me is extremely misguided as the types of people to rely on a GUI are not going to be those capable of custom coding and a blank screen in your favourite code editor is also capable of being turned into your wildest dreams with the right coding skills.
I hope this post saves people a lot of searching and, along with responses, combines the various posts into one topic, illustrates the need for it and, with a bit of optimism, actually leads to the matter being solved once and for all as its been going on for 5 years too long and I suspect most people here (that are not on the Development Team or associated with them) would agree.
The Code for Doing It Yourself
I notice many who have asked have subsequently not shared their solutions for doing it themselves.
With gratitude and full credit to @Jason-Dang on the Suite CRM Development - he has said the following and given me permission to share it:
…This requires custom code if you want to attach a parsed PDF. You can add attachments to email templates including PDFs but these would be static and not parsed with user data…
To get you started what you’ll need to do is (in a logic hook or whatever):
Load your email and PDF template beans.
Build an array of beans you want to parse the templates with:
'{ModuleName}' => '{recordId}'.
For email templates you can call parse_template on the template object and pass in the subject, body and bean array like below:
$subject = $emailTemplate->parse_template($emailTemplate->{'subject'}, $beanArray);
$body = $emailTemplate->parse_template($emailTemplate->{'body'}, $beanArray);
$bodyHtml = $emailTemplate->parse_template($emailTemplate->{'body_html'}, $beanArray);
For the PDF, use the templateParser class instead as the placeholder variables they parse differ (plural vs singular).
You’ll want to essentially replicate most of what’s in modules/AOS_PDF_Templates/generatePdf.php, replacing html/js and template variables, then use mPDF to generate the file, output it to the server (temp or permanent depending on use cases).
Lastly with your parsed templates, you use SugarPHPMailer to send the email with the parsed email template and the parsed PDF attached (You can find examples of this within the core of Suite).