1

I have tried appending __c and __r as other threads have suggested, but I haven't had any luck yet--maybe I'm reading their advice incorrectly. I'm working on my first visualforce email template and when I attempt saving it I get an error message: "Error: Invalid field Display_Name for SObject Event"

The little bit of code that generates it is:

<messaging:emailTemplate subject="You Are Registered!" recipientType="Contact" relatedToType="Event">
<messaging:plainTextEmailBody >
Hello!
Thank you for registering for our {!relatedTo.Display_Name}.

What can I do to have it recognized as a valid field?

5
  • Can you confirm there is a field on Contact whose API Name is Display_Name__c?
    – Adrian Larson
    Commented Nov 3, 2016 at 16:12
  • No; that field is on Event, the "relatedToType"
    – bblohowiak
    Commented Nov 3, 2016 at 16:44
  • Right, Event. That's what I meant. Can you confirm the exact API Name does, in fact, exist?
    – Adrian Larson
    Commented Nov 3, 2016 at 16:45
  • The exact API Name is "EventApi__Display_Name__c." I replaced it and got pretty much the same error message, "Invalid field EventApi__Display_Name__c for SObject Event"
    – bblohowiak
    Commented Nov 3, 2016 at 17:39
  • 1
    I realized that I needed to get the API Name for the custom object that was the relatedToType correct: "relatedToType="EventApi__Event__c"". That helped!
    – bblohowiak
    Commented Nov 3, 2016 at 20:37

1 Answer 1

0

Every API Name must be exact. You should be able to run the following snippet in Execute Anonymous by putting the two together if you use relatedToType="MyObject__c" and {!relatedTo.MyField__c}:

SObjectField mergeField = MyObject__c.MyField__c;

In this case you need to double check Event and Display_Name__c.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .