1

enter image description hereI've got a workflow that runs every time a Foo__c is inserted and sends an Email Alert to the Related Contact Foo__c.Contact__c.

According to this: https://developer.salesforce.com/forums/?id=906F00000008uu1IAA , I should be able to reference the Related Contact by writing {!Contact.FirstName} in the Email Template. However, this is not working. The space where I've put that merge field at comes back blank when sent to me.

I know a potential solution here is to create a formula field on my Foo__c object that exposes the contact's first name, but that seems like not a best practice.

Can someone confirm which way I should be doing this or explain why that developer.salesforce.com post indicates that {!Contact.FirstName} should work. Is that post wrong?

1

From within workflow, the related contact should already be in the context of the workflow. That's why {!Contact.FirstName} should work.

However, if the field isn't populated in the contact's record, workflow won't be able to enter data for it in the template. I suggest you test your template with a record you know has valid data in the {!Contact.FirstName} field. Unless you absolutely need the FirstName only, it would be preferable to use {!Contact.Name} since by default, only the LastName is a required field in an org.

| improve this answer | |
  • I tried putting all 3 of {!Contact}, {!Contact.Name} and {!Contact.FirstName} in my email template. None of these worked and all came through as blank. Both the first/last name are populated in the contact record. – frontendloader Aug 19 '15 at 17:17
  • A couple of questions here. Are fields from your foo__c object showing up in your email? In your workflow, did you define the contacts to use in the email alert in workflow as beginning from Contact object or beginning relative to the foo__c object record? – crmprogdev Aug 19 '15 at 19:48
  • Yes fields from the Foo__c are showing up in the email. The email alert is defined beginning relative to the Foo__c object record. See attached image in original question. – frontendloader Aug 20 '15 at 13:43
  • Did you update (click on edit at bottom left of your post) to include your image? If not, I don't see any link to it. It sounds like you did it properly in your workflow. Have you tried changing your template to use {!Foo__c.Contact__r.FirstName}? It could be that in the post you cited, a specific contact was referenced. It can be done either way in workflow; esp if more than one contact is being referenced. – crmprogdev Aug 20 '15 at 14:07
  • It's blank that way as well. – frontendloader Aug 20 '15 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.