Generate and send invoice/quote PDFs via mail composer

When utilizing the “Email PDF” feature within the Invoice/Quote modules and selecting an invoice email template, I’ve noticed that the inserted fields, such as $aos_invoices_invoice_date, fail to populate with their actual values.

Has anyone encountered a similar issue or have any insights into what might be causing this discrepancy? Any assistance or suggestions would be greatly appreciated.

How did you notice the inserted fields failed to populate with their actual values?

In Mail body the variables are not replaced with their values.

use pdf to email, all the variables is ok

Many thanks for your help, but what do you mean? I’m not sure I understand what you mean by 'use PDF to email.

Capture d’écran 2024-04-25 à 07.48.16
You can create a quote pdf and when you “Email pd” The pdf is the body mail

Many thanks, I know how to do this, but I want to create an “Email PDF” because I want to send invoices/quotes to our customers with attachments, and the body should come from the “EMAIL - TEMPLATES” module.

Personally, I use email pdf for the body of the mail . And I attach the attachment manually .

Thanks for your quick feedback. But I want to use another email template and send the invoice with attachments.

I hope someone have an idea.

The variables of email template are not as rich as the pdf template.
Also, they depend on the module from which the email is sent, if it is from the contact, we will be able to retrieve the name of the contact but not the information of an invoice or a quote (Or then I did not find)
That’s why I use the pdf email .

I least a can get info such as account name

You’re using the wrong variable. There is no account_name associated with a quotation. The field you’re using is when your sending an email to an account then you would use account_name. If however you are making an email template to send to the billing account on a quote, you must use the proper fields:

$aos_quotes_billing_account

You can ONLY use variables from the Quotes module if you intend to send the email as quotes.

Same for invoices. You will need to create a specific email template because the variable for the billing account is:

$aos_invoices_billing_account

This function no longer works for us after upgrading our system from 7.8.5 to v7.13.4. Specifically, email templates that have been configured with fields like “$aos_invoices_name” now do not parse those fields UNLESS we manually change the Related To: relationship from the “Contact: [contact name]” to the “Invoice: [invoice title]”.

We’re not sure how to trace the cause. The invoice data would always get pulled in and parsed before our system upgrades. There are no PHP or SuiteCRM error log entries that give us a clue.

We would appreciate any help. Could some relationship between the modules have broken? We have tried QR&R as well as other repair and rebuild tools in our instance.

Our Process:

  • Invoice Detail View
  • after clicking Email PDF, the Compose Email window loads with the PDF attachment
  • we choose the email template with its fields
  • we send email
  • email is successfully sent and received, but the dynamic field data has not been parsed

Hey @franklinian that won’t work unless the parent relation is the invoice. The contact John Robinson does not have any of the invoice data in his record.

In SuiteCRM v7.8.5, if John Robinson was the Contact already attached to the saved invoice I was emailing, the dynamic $aos_invoices_ fields in my template DID parse correctly using the settings you see in my screenshot above. We did another rollback of our instance to confirm…

I really appreciate the helpful feedback. What am I still missing from this picture? I’m not a programmer and so am not sure how to break these components down further to uncover what’s different.

Unless you make the relation to the invoice, I don’t think that will work for you. 7.8.5 is pretty old. I believe email was completely redesingned since then many times. I’ve never been able to get a variable from a related record with email. Only variables from the directly related object. In your case, the invoice.

You can assume there are many invoices associated to a person. If you make the main association of the email to the person how would SuiteCRM know which invoice to pull the data from? (It wouldn’t). You need to direcly relate the email to the invoice then you should have no problem populating the invoice variables in the email.