function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ClubliClubli 

I need help creating a visual force email template.

Hi,

 

I'm trying to create a VF template for cases that will include the related Solution (from the Solutions related list on Cases).

 

I am getting an error: "Error: Invalid field Solution__r for SObject Case"

 

The code is as follows:

 

<messaging:emailTemplate subject="Test VF" recipientType="Contact" relatedToType="Case">
<messaging:htmlEmailBody>
<html>
<body>
<table border="0" >
<tr>

<th>Solution Detail</th>
<th>Solution Title</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Solution__r}">
<tr>

<td>{!cx.SolutionNote}</td>
<td>{!cx.SolutionName}</td>
</tr>
</apex:repeat>
</table>
<p/>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

 

Is what I want to do possible? And if so, can you help me with the error I am receiving.

 

Thanks!!

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

The solutions associated with a case have the name 'CaseSolutions', rather than Solutions__r - the __r notation indicates a custom relationship rather than a standard one.

All Answers

bob_buzzardbob_buzzard

The solutions associated with a case have the name 'CaseSolutions', rather than Solutions__r - the __r notation indicates a custom relationship rather than a standard one.

This was selected as the best answer
ClubliClubli

Thanks, but when I change it to "CaseSolutions" I receive the same error.

 

"Error: Invalid field CaseSolutions__r for SObject Case"

 

Any ideas?

bob_buzzardbob_buzzard

You don't need the __r on the end.  You would only need that if it was a custom relationship that you had created.

ClubliClubli

Thanks so much. Its working now.

 

Thank again.

 

 

bob_buzzardbob_buzzard

Can you mark it as the solution for those that come after us.

RGK.ax912RGK.ax912

This does not seem to work correctly, I get the following error message:-

 

Error: Invalid field SolutionNote for SObject CaseSolution

 

I have used the following code:-

 

<messaging:emailTemplate subject="Test VF" recipientType="Contact" relatedToType="Case">
<messaging:htmlEmailBody>
<html>
<body>
<table border="0" >
<tr>

<th>Solution Detail</th>
<th>Solution Title</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.CaseSolutions}">
<tr>

<td>{!cx.SolutionNote}</td>
<td>{!cx.SolutionName}</td>
</tr>
</apex:repeat>
</table>
<p/>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 Can you tell me what is wrong.

 

Thanks

bob_buzzardbob_buzzard

CaseSolution is an object that relates a case to a solution, but SolutionNote is a field on the Solution object.  Thus you'd need to follow the relationship to the solution in question:

 

<td>{!cx.Solution.SolutionNote}</td>
<td>{!cx.Solution.SolutionName}</td>