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
Mehul MakwanaMehul Makwana 

How to render Div tag based on condition

Hello Developers,

In VF email template want Amount field to be rendered based on IF condition like if currency is JYP or USD then render.
<div style="{!IF({!relatedTo.Related_Opportunity__r.CurrencyIsoCode}='JYP', 'display:block', 'display:none')}" >            
Amount : <apex:outputText value="{!relatedTo.CurrencyIsoCode}" rendered="true" /> 
</div>

Please Note: I do not want to go for controller want to achive this through VF Email template only.

Thanks
Mehul
 
Best Answer chosen by Mehul Makwana
Sohan Raj GuptaSohan Raj Gupta
I have also added == for compare values. Share what error you are getting.

Please also try below code:
 
<div style="{!IF((relatedTo.Related_Opportunity__r.CurrencyIsoCode=='JYP' || relatedTo.Related_Opportunity__r.CurrencyIsoCode=='USD'), 'display:block', 'display:none')}" >            
Amount : <apex:outputText value="{!relatedTo.Related_Opportunity__r.CurrencyIsoCode}" rendered="true" /> 
</div>

 

All Answers

Sohan Raj GuptaSohan Raj Gupta
Hi Mehul,

Try below code and let me know is it working or not.
 
<div style="{!IF(({!relatedTo.Related_Opportunity__r.CurrencyIsoCode}=='JYP' || {!relatedTo.Related_Opportunity__r.CurrencyIsoCode}=='USD'), 'display:block', 'display:none')}" >            
Amount : <apex:outputText value="{!relatedTo.CurrencyIsoCode}" rendered="true" /> 
</div>

Hope this will help you. Let me know if it helped or you need any more assistance. 

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta 
Mehul MakwanaMehul Makwana
Hi Sohan,
Thanks for the reply, you have give me same code with OR condition and it's give me same syntax error.
Can you please help me to fix the syntax error.
Sohan Raj GuptaSohan Raj Gupta
I have also added == for compare values. Share what error you are getting.

Please also try below code:
 
<div style="{!IF((relatedTo.Related_Opportunity__r.CurrencyIsoCode=='JYP' || relatedTo.Related_Opportunity__r.CurrencyIsoCode=='USD'), 'display:block', 'display:none')}" >            
Amount : <apex:outputText value="{!relatedTo.Related_Opportunity__r.CurrencyIsoCode}" rendered="true" /> 
</div>

 
This was selected as the best answer
Ravi Dutt SharmaRavi Dutt Sharma
Hi Mehul,

Put the div inside an output panel and rerender the output panel. Hope that helps.
Sohan Raj GuptaSohan Raj Gupta
Hi Mehul,

You can also try below code:
 
<apex:outputPanel rendered="{!IF((relatedTo.Related_Opportunity__r.CurrencyIsoCode=='JYP' || relatedTo.Related_Opportunity__r.CurrencyIsoCode=='USD'), true, false)}">
	<apex:outputText value="{!relatedTo.Related_Opportunity__r.CurrencyIsoCode}" rendered="true" /> 
</apex:outputPanel>

Hope this will help you. Let me know if it helped or you need any more assistance. 

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta