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
- This email HAS WORKED! I can NOT reproduce the situation where it did work, but it definitely has!
- 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. |
Send via process builder | Hey, it's worth a shot! But of course, since it just uses the standard email alert, it won't do anything different. | Nope, no difference. |
Sent the email from another object | I used a workflow to update ObjectA then send the email from there - it did not work even though there are other emails sending from that object quite fine. | ! AAAGHHH! |
Dialed back the API version | So, what was the difference between the email that was working and the one that was not? The API Version. The working email was on 32, the non working was on 33 | Nope! |
So, at this stage we know, it's not about the data model and it's not about HTML visualforce. It's not about the HTML structure and it's not about whether the fields are enclosed in output tags or not. It is only about whether the fields are custom fields or not.
I could test with another object but I need to send from this object.
I could test without visualforce emails but I need to use visualforce emails to have conditional text in this email.
Add Comment