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
KnewTVsKnewTVs 

How to filter related list in an email template approachbutwithnoluck

I need to filter a related list for the active inventory in a related list. Similar to this question:

http://community.salesforce.com/t5/Visualforce-Development/Visualforce-Email-Template-Display-filtered-Opportunty-Report/m-p/148071

 

This is simple in an XSLT implementation.

 

I found the following:

http://community.salesforce.com/t5/Visualforce-Development/Visualforce-email-template-On-Account-displaying-all/m-p/154143#M18324

<apex:dataTable value="{!relatedTo.Opportunities}" var="o">

<apex:column value="{!o.Name}" rendered="{!o.IsClosed == false}"/>

<apex:column value="{!o.CloseDate}" rendered="{!o.IsClosed == false}"/>

</apex:dataTable>

 

This seams a lot easier than having to write a customer controller.

I have tried to apply the rendered="{!o.IsClosed == false} approach to the following code with no luck.

 

Any suggestions?

 

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

<tr>

<td WIDTH=100 >{!cx.Year__c}</td>

<td WIDTH=200>{!cx.Make__c}</td>

<td WIDTH=300>{!cx.Model__c}</td>

<td WIDTH=200>$<apex:outputText value="{0,number,00,000}"> <apex:param value="{!cx.ri__ListPrice__c}"/> </apex:outputText> </td>

<td WIDTH=200><img src={!cx.ri__Unit_Main_Image__c} height=100 width=150 alt={!cx.Model__c} /></td> </tr> </apex:repeat>


NeuNetTeamNeuNetTeam

You should create a formula field on your object that returns a Boolean (true / false) text value or use a checkbox standard field like IsClosed or IsWon.

 

For example

Show = If(condition,"true","false")

 Then the example you found becomes:

<apex:dataTable value="{!relatedTo.Opportunities}" var="o">

<apex:column value="{!o.Name}" rendered="{!o.show__c}"/>

<apex:column value="{!o.CloseDate}" rendered="{!o.show__c}"/>

</apex:dataTable>

 To make this work in HTML rather than APEX, you need to embed the conditional inside the brackets:

 

<apex:repeat var="cx" value="{!relatedTo.[Related List Name]}">

<tr>

<td WIDTH=100 >{!IF(show__C,cx.Year__c,"")}</td>

<td WIDTH=200>{!IF(show__C,cx.Make__c,"")}</td>

<td WIDTH=300>{!IF(show__C,cx.Model__c,"")}</td>

<td WIDTH=200>$<apex:outputText value="{0,number,00,000}"> <apex:param value="{!cx.ri__ListPrice__c,"")}"/> </apex:outputText> </td>

<td WIDTH=200><img src={!cx.ri__Unit_Main_Image__c} height=100 width=150 alt={!IF(show__C,cx.Model__c,"")} /></td> </tr> </apex:repeat>

 

The only issue with using HTML vs. an apex:DataTable is that the render = fales parameter prevents a blank line in the table.  Your HTML code will generate a line return every time you process the <tr> tag.

 

Unless I am not understanding what you are referencing, I believe your reference to ri__Units__r is wrong.  It should be the Object.Related_Object_Plural_Name.

 

Hope that helps.

 

NeuNet Consultants