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
WilksyWilksy 

VisualForce email template using Apex:repeat

Hi
 
There's an example here to create a VisualForce email template: 
 
 
How would I go about changing this code so that there is a 'where' clause on the cases that are returned in the apex:repeat list?
 
<apex:repeat var="cx" value="{!relatedTo.Cases}">       <tr>           <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |             <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>           <td>{!cx.CaseNumber}</td>           <td>{!cx.Subject}</td>           <td>{!cx.Contact.email}</td>           <td>{!cx.Status}</td>       </tr> 
</apex:repeat>  
Best Answer chosen by Admin (Salesforce Developers) 
WilksyWilksy

Great - works first time.

Simple solution.

All Answers

kxa422kxa422

You can try to use a output panel with a rendered part.

<apex:repeat var="cx" value="{!relatedTo.Cases}"> <apex:outputPanel rendered="Your Condition"> <tr> <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> | <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td> <td>{!cx.CaseNumber}</td> <td>{!cx.Subject}</td> <td>{!cx.Contact.email}</td> <td>{!cx.Status}</td> </tr> </apex:outputPanel> </apex:repeat>

 

 

WilksyWilksy

Great - works first time.

Simple solution.

This was selected as the best answer
Glenn at MvistaGlenn at Mvista

Help a newbie - what was the format for "Your Condition:"?

Glenn at MvistaGlenn at Mvista

Found it - should have queried a bit more before asking.

 

For example: <apex:outputPanel rendered="{!cx.Status = 'Open'}">

elyb527elyb527

I am trying to modify this to use Cases and the related Parts which is a custom object.

 

When I change the line 

 <apex:repeat var="cx" value="{!relatedTo.Cases}">

to

 <apex:repeat var="cx" value="{!relatedTo.Parts__c}">

 

I get the error:Invalid field parts__c for SObject Case.

 

Any ideas what I am doing wrong???

 

Thanks for any help

Elly

WilksyWilksy

Hi

 

Try

 

<apex:repeat var="cx" value="{!relatedTo.Parts__r}">

elyb527elyb527

Thank you SO much!!! Didn't think of that - DUH!