I don't know if I will find an answer to this, but I am having a mysterious problem with visualforce emails not populating with data when being sent via a workflow, but they do send fine when sent via the Send Test and Verify Merge Fields button.
Other Reports
- http://salesforce.stackexchange.com/questions/22568/approval-process-step-field-update-doesnt-appear-in-same-steps-visualforce-ema (It's not an approval).
- https://developer.salesforce.com/forums/ForumsMain?id=906F00000008lpRIAQ (no answer, and their data model is simpler, so I think it is not to do with the data model)
- https://success.salesforce.com/issues_view?id=a1p30000000SdBfAAK (It's not the same because this is saying the workaround is to use relatedTo, which I am).
- https://success.salesforce.com/answers?id=90630000000h2ywAAA (does not actually answer the question).
Data Model
Notes
- VF Email is being sent from Custom Object B and contains fields from all related objects.
- Emails sent from Custom Object A work with no problem.
- Values from Custom Object C show fine.
- The VF Email Template header is
<messaging:emailTemplate subject="My Email Subject" recipientType="Contact" relatedToType="ObjectB__c" rendered="true">
Steps
Steps to try to work out what the problem is and fix it
Step | Notes | Result |
---|---|---|
Create formula fields for data | rather than {!relatedTo.ObjectA__r.Campaign__r.Account__r.Notes__c} I added the Notes field to Object B as a formula field so it was {!relatedTo.Notes__c} I did this for 3 fields | No fields displayed |
Send email immediately | The workflow was running after an hour | No fields displayed |
Simplified the HTML Email | No fields displayed | |
Added the IDs for all the objects into the email body | ALL IDs Displayed!! | |
Added the Names | If the Standard Fields of IDs display, do the standard fields of Names display? Because the field that is displaying from ObjectC is the Name field. | All Name fields displayed!! |
Added the new fields without any HTML embellishment | Just replaced the name fields that did display with the fields I wanted to display. | No Custom fields displayed! |
Wrapped the fields in the output tags | To try to see if there was anything to the non-answer in article 4. above. I also added Created Dates (standard fields) in output tags. | No Custom fields displayed. Standard fields displayed |
Changed to plaintextemailbody | Nope, so it's not about HTML | |
Changed the Contact lookup to be directly from Custom Object B | So instead of {!relatedTo.ObjectA__r.Contact.Notes__c} I had {!relatedTo.Contact__r.Notes__c} | Nope, so it's not about how far away the object is at all. |
Add Comment