2

I am following this SF VF email example.

They have the relatedToType="Account" and their <apex:repeat var="cx" value="{!relatedTo.Cases}"> references Cases which should loop through the Cases related to Account - Being a one to many relationship. I can make this work fine.

When I change the relatedToType="Contact" and my <apex:repeat var="cx" value="{!relatedTo.MyCustomObject__r}"> which is also a one to many relationship I get the following error on trying to save the template:

Error: Invalid field MyCustomObject__r for SObject Contact

I have also tried __c but with the same error.

Any ideas?

UPDATE:

The accepted answer below (and comments) worked for me. I was focusing on the related 'object' not the 'field' that actually related them both together.

2
  • 1
    Get the child relationship name and append __r there . Jan 8, 2016 at 12:39
  • 2
    The child relationship name is usually plural (unless you've manually changed it), and you have to use __r. So use {!relatedTo.MyCustomObjects__r}. You can see the child relationship name, by going to the lookup field, it's at the bottom left. Jan 8, 2016 at 12:42

1 Answer 1

5

The child relationship name has to be observed and __r needs to be appended .

enter image description here

In your set up menu navigate to Object > field > and observe child relationship name

You must log in to answer this question.

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