0

I'm trying to send 3 different email using a single email template and visualforce component. I'm using rendered to display the text in html email vf component based on conditions. However, when I'm trying to add 3 different subject lines in email template subject, it does not let me save and throws and error : 'syntax error'.

I'm not sure what's wrong here. any help would be much appreciated.

Cheers! :)

<messaging:emailTemplate subject="{!If({RelatedTo.order_status__c} =='Cancelled','Revision Required for Trade Event Order : {!RelatedTo.Name}',{!If({RelatedTo.order_status__c} == 'Approval Requested','Approval Requested For : {!relatedTo.Name}','Approved')})}" recipientType="User" relatedToType="GTS3_Trade_Event__c">
<messaging:htmlEmailBody >
<c:TradeEventOrder_CancelAndSubmission tradeEventOrderId="{!relatedTo.Id}"/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
  • What does that 'Syntax error' say? Can you please provide more information by editing your question? – Arnold Jr. Sep 13 '18 at 14:49
  • @ArnoldJr. It just says 'Error: Syntax error'.. That's it.. there is no other statement to describe what's not being done the right way. – Ashutosh Arora Sep 13 '18 at 14:50
1

The error is that you're using the merge syntax inside of merge syntax.

{!If({RelatedTo.order_status__c} =='Cancelled','Revision Required for Trade Event Order : {!RelatedTo.Name}',{!If({RelatedTo.order_status__c} == 'Approval Requested','Approval Requested For : {!relatedTo.Name}','Approved')})}

Try

{!If(RelatedTo.order_status__c =='Cancelled','Revision Required for Trade Event Order : ' & RelatedTo.Name, If(RelatedTo.order_status__c == 'Approval Requested','Approval Requested For : ' & relatedTo.Name,'Approved'))}

Update

I edited the question a few times to try to make sure I was getting the syntax correct. Hopefully it'll work as it is but if you run into errors with what I posted feel free to add a comment so I can fix it.

  • Make sure you accept the answer so others know your issue is resolved. – gNerb Sep 13 '18 at 14:56
  • My answer shows you exactly what you need to do already. – gNerb Sep 13 '18 at 15:09

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.