Hi I have create the Visualforce email template and i have attach the pdf file,in that pdf file name has been Certificate .pdf, but the file name a particular parent name Eg: Mecca Bingo it will show email out upon the pdf file name merging the Four filed name.

I have create the IF statement in email template but it has been show the error.

<messaging:attachment filename="{!relatedTo.Site__r.AM_UPRN__c}-

this is my merged file name but i have tried for if statement

<messaging:attachment filename="{!If(relatedTo.Site__r.Name='Mecca Bingo',
relatedTo.Site__r.AM_UPRN__c,'Certificate.pdf')}" renderAs="pdf"> 

It was working nice but i need check the second one merged fields check the if statement i have tried it was occure the error


But I need to check in this format to IF statement

<messaging:attachment filename="{!If(relatedTo.Site__r.Name='Mecca Bingo',
{!relatedTo.Date__c}),'Certificate.pdf')}" renderAs="pdf">

Please anyone kow let me know...

Thanks in advance :)

  • Unless you use the {} button (or manually indent by 4 spaces) characters like < and > are not escaped so Visualforce markup renders badly. Best to use {} on all Apex and Visualforce - I've don it for you. – Keith C Aug 5 '14 at 9:59

Try this:

<messaging:attachment filename="{!If(relatedTo.Site__r.Name='Mecca Bingo',
relatedTo.Date__c),'Certificate.pdf')}" renderAs="pdf">
| improve this answer | |
  • Hi.. thanks for ur answer and Replay. i have done the IF Statement. in this format. Thanks for ur Priceless Post.. :) – Parthipan Francis Aug 6 '14 at 11:07

The "Visualforce Function" docs provide examples for their functions. Check out the IF and CASE functions.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.