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
bprakashbprakash 

Title for datatable in Visual force email template

In visual force email templates,Can we make the <span > tag invisible if the table below the tag is empty means no values are there in the table?

iam using the datatable  in visualforce email template,and the title given for this datatable by using <span> tag 'My Test' .My Test is the title for datatable.

 

Is this the way i need to do,or there is another way/

 

My requirement is whenever there are no values are in datatable i need to make the title invisible,this needs to be done in visualforce email template

 

Thanks

Kan

craigmhcraigmh

You can use the rendered attribute of the datatable, or wrap what you want hidden in an output panel, and use the rendered attribute of that.

 

rendered="{!yourRecordVar.size > 0}

bprakashbprakash

Hi Thanks for the reply,

Can you please elaborate this,

my code is some what like this

 

<span class="sectionTitle">Product License</span><br/>
<table border="0" cellspacing="0" cellpadding="4" class="list">
        <tr >
        <th>Serial Number</th>
        <th>MAC</th>        
        <th>Product</th>
        <th>Type</th>
        <th>Key</th>       
    </tr>
    <apex:repeat var="SN" value="{!relatedTo.ContractLineItems}">
       <apex:outputPanel layout="none" rendered="{!SN.PricebookEntry.Product2.License_Feature__r.Name  == 'Appliance product type' }">
           
    <tr>
        <td> {!SN.Asset.Name} </td>
        <td> {!SN.Asset.MAC_Formatted__c} </td>
        <td> {!SN.PricebookEntry.Product2.Name} </td>
        <td> {!SN.PricebookEntry.Product2.Level__c} </td>                 
        <td> {!SN.Key__c} </td>
    </tr>
       </apex:outputPanel>    
    </apex:repeat>
</table>

 

i want to hide the 'product license' when datatable is empty,no child objects for tht

 

Thanks

Bhanu

 

craigmhcraigmh

<apex:outputPanel rendered="{!relatedTo.ContractLineItems.size > 0}">

<span class="sectionTitle">Product License</span><br />

</apex:outputPanel>

bprakashbprakash

<apex:outputPanel rendered="{if(!relatedTo.R00N40000001raV3EAI__r).size() > 0}">   
<span class="sectionTitle">Product Licenses</span><br/>
</apex:outputPanel>
<table border="0" cellspacing="0" class="list">
    <tr>
        <th>Serial Number</th>
        <th>Product</th>
        <th>Type</th>
    </tr>
            
    <apex:repeat var="SN" value="{!relatedTo.R00N40000001raV3EAI__r}">
     
    <tr>
        <td>{!SN.gii__SerialNumber__c}</td>
        <td>{!SN.gii__ProductReference__r.Name}</td>
        <td>{!SN.gii__SalesOrderLine__r.Line_Type__c}</td>        
    </tr>
    </apex:repeat>
    
</table>
i used like this

it has two records iam getting records but not the Product License.

can you please take a look,thanks

for your help

 

bprakashbprakash

sorry to bother you but its genuinely required for my subscription templates

Thanks

craigmhcraigmh

Test for the size of the collection used to populate your repeat control.

 

<apex:outputPanel rendered="{!relatedTo.ContractLineItems.size > 0}">
<span class="sectionTitle">Product License</span><br />
</apex:outputPanel>
<table border="0" cellspacing="0" cellpadding="4" class="list">
        <tr >
        <th>Serial Number</th>
        <th>MAC</th>        
        <th>Product</th>
        <th>Type</th>
        <th>Key</th>       
    </tr>
    <apex:repeat var="SN" value="{!relatedTo.ContractLineItems}">
       <apex:outputPanel layout="none" rendered="{!SN.PricebookEntry.Product2.License_Fea​ture__r.Name  == 'Appliance product type' }">
           
    <tr>
        <td> {!SN.Asset.Name} </td>
        <td> {!SN.Asset.MAC_Formatted__c} </td>
        <td> {!SN.PricebookEntry.Product2.Name} </td>
        <td> {!SN.PricebookEntry.Product2.Level__c} </td>                 
        <td> {!SN.Key__c} </td>
    </tr>
       </apex:outputPanel>    
    </apex:repeat>
</table>

 

bprakashbprakash

i tried this before its not showing the span but iam getting values in the table,what i need to make this?

and iam using this for visualforce email template,its not showing product license,if the table is not empty i dont want to show the product license header,

this will be greatful for me and the firm.

Thanks

kan

bprakashbprakash

ErrorError: Invalid field 'size' for SObject 'ContractLineItem'.

so i used size() its still showing error for method

Thanks

Bhanu

craigmhcraigmh

Odd, you don't need the parentheses.

 

And since ContractLineItem should be a collection of some sort, since you're using it as the value for the repeater, it should have the size() method available.

bprakashbprakash

is that some what we can do this ?bcos iam getting error i dont know its some what we can do or we cannot in visualforce?

thanks a lot