Now that the PDFs are generated automatically, Linda also wants to configure the sending of these invoice PDFs to customers.

Trigger conditions on the invoice object
In order to ensure the proper functioning of the automation, it is necessary to check whether
Auto issuance is checked
the PDFs were created correctly and
if the contacts are filled out correctly on the invoices owing to retrieve email addresses.
Note: The conditions are given as an indication and need to be customize according to your business needs. If you want to add additional conditions, don't hesitate.
Contact OK Formula field (Check box)
This formula is based on the Salesforce field on the Contact object:
Please adapt the condition due to your business needs. | |
PDF OK
The formula is based on these packaged fields of the Invoice PDF object:
Please adapt the condition due to your business needs. |
Set up the fields needed for the automation
The Automatic issuance check box already exists in the objet, PDF OK was already configured when the Automation: Invoice Issuance was implemented.
We recommend to read these trailhead articles, if you did not have occasion to train yourself on these topics:
Steps
1. Go to Setup > Object Manager > Invoice
2. Click on Fields & Relationships
3. Click on New
4. In Step 1: Choose the field type Formula
5. In Step 2: Choose the output type Checkbox and insert the field label Contact OK
6. In Step 3: Switch to the tab Advanced Formula and compose the formula that fits to your business needs.
Note: If you copy this formula from the top of the article, please paste it into a text editor in order to take off the formatting of the text. It happens that the Formula editor does not accept copy pasted formulas due to the formatting.
7. Verify the formula syntax.
8. Insert a telling description and a help text that explains the field to the users.
9. In Step 4: Establish field-level security by checking the boxes of the profils you want to give the right to modify the field, according to your company security policies.
10. In Step 5: Instead of checking the box here, we recommend to go to each page layout of the invoice object you want to put the fields on, in order to put them manually in the right section.
Note: In order to easily debug the process, if an invoice is not processed, because of a missing contact, make life easier for users - and reduce your work - by putting the formula in a non-technical language in the help text of these fields.
When the user understands why the process is not working for an invoice, he or she can modify the invoice to meet the conditions or at least understands why the invoice has not been processed.
Note: Please repeat these steps with the PDF OK field, if you haven't set it up in one of the previous automations.
Here you can see Linda's results:

Following the creation of this field, we create an Email template to use in the process.
Creation of an Email template in order to sent out the PDF invoices
Steps
1. Do one of the following:
If you have permission to edit public templates, from Setup, enter Email Templates in the Quick Find box, then select Classic Email Templates.
If you don’t have permission to edit public templates, go to your personal settings. Enter Templates in the Quick Find box, then select Email Templates or My Templates—whichever one appears.
2. Click New Template.
3. Choose the Text template type, and click Next.
4. Choose a folder in which to store the template.
5. To make the template available for use, select the Available For Use checkbox.
6. Enter a name in Email Template Name like Invoice PDF sent out
7. Insert a Subject and add fields thanks to the wizard, like
Invoice {!sofactoapp__Factures_Client__c.sofactoapp__Reference__c} - {!sofactoapp__Raison_Sociale__c.Name}8. Compose the Body of the message and add also fields thanks to the wizard, like
Dear {!Contact.Name},
Please find attached your invoice from {!sofactoapp__Factures_Client__c.sofactoapp__Date_de_facture__c}.
Do not hesitate to contact {!Contact.OwnerFullName} - {!Contact.OwnerEmail}, if you have any open questions left.
Best regards,
Your {!sofactoapp__Raison_Sociale__c.Name} team.
9. Save.
Email alert in case the contact is not filled out correctly
Repeat this procedure in order to create an email template for an email alert in case the contact is not correctly filled out in the invoice.
Exemple for an email template name:
Email of the invoicing contact missingExemple for an email subject:
No email address configured for:{!sofactoapp__Factures_Client__c.sofactoapp__Contact__c} de {!sofactoapp__Factures_Client__c.sofactoapp__Compte__c}Example for the body of the email:
{!Account.OwnerLastName},
Please fill out an email address for {!sofactoapp__Factures_Client__c.sofactoapp__Contact__c} that is linked to the account {!sofactoapp__Factures_Client__c.sofactoapp__Compte__c}.
Please verify afterwards in the activities that the invoice {!sofactoapp__Factures_Client__c.sofactoapp__Reference__c} was sent via email.
Now that the prerequisites are prepared, let's start to configure the process.
Testing approach
After the configuration, don't forget to test our process.
Preparation
First make sure you have an invoice available that meets the criteria
For example in the case of Cloud Kicks:
The invoice status is issued
There is a PDF that exists
The invoice is not a proforma
A contact (with email address) is linked to the invoice
and that you have added the Contact OK field, and, if not yet done, also the PDF OK field in your page layout.
Steps
A) Create an invoice that fulfills the conditions
> As soon as the invoice fulfills the conditions, it must be processed by the process.
B) If the invoice already existed and it has already fulfilled the conditions:
1) Add a contact
2) Save the invoice
or
1) Remove the contact
2) Save the invoice
3) Add the contact again
> This triggers the process again.
Note: Do not forget to test the case of an invoice with PDF and without Contact.
Was the test successful?
If not :
1) Check the configuration of your fields
2) Did the test invoice fulfill the conditions of the process builder?
3) Check the configuration of the process builder by comparing with this article.