You need to sign in to do that
Don't have an account?
Email Template VF Page binding error
I'm trying to package an email template accessing a custom object generation an attachment. It work fine in a DEOrg but as soon as I try to package it in a separate DEOrg I get an error saving the VF Email template. Here the namespace prefix is XXX and the custom object is person with a field called first_name__c.
Error occurred trying to load the template for preview: Could not resolve field 'first_name__c' from <apex:outputField> value binding '{!relatedTo.first_name__c}' in page XXX:Test_Email_Template. Please try editing your markup to correct the problem.
The VF code:
<messaging:emailTemplate subject="Test" recipientType="Contact" relatedToType="XXX__person__c"> <messaging:plainTextEmailBody > Congratulations! This is your new Visualforce Email Template. </messaging:plainTextEmailBody> <messaging:attachment renderAs="pdf" filename="{!relatedTo.name}"> <apex:panelGrid columns="1" > <apex:outputField value="{!relatedTo.first_name__c}"/> </apex:panelGrid> </messaging:attachment> </messaging:emailTemplate>
It the code is changed to <apex:outputText value="{!relatedTo.first_name__c}"/> it works ok so it binds to the custom object ok.
The only difference between the DE's I can figure is that the namespace prefix is used in this code for packaging. Anyone got any ideas?
I have identified the issue (thanks to Salesforce.com support) and because it is a bit obscure I will recount it for anyone else that hits the same problem.
Apparently the 2 Orgs I have been using differ in one critical way; with only one activated for multi-currency support. Therefore, if you have an Org that is not multi-currency activated the use of <apex:outputField> will work fine BUT be warned it will fail if you have multi-currency activated. In other words it has nothing to do with the namespace prefix as I initially thought.
That is a big issue if you need to generate managed packages where the managed package Org is already activated for multi-currency. It means the same source code will not compile and cannot be packaged up.
This seems to be a significant oversight because plenty of companies use multi-currency even if they are totally based in North America. A foreign product catalog for example where you maybe want to send a standard email.
A work-around has been posted on the blog:
Link of Community board:- Pages 1 & 2.
http://boards.developerforce.com/t5/Visualforce-Development/Visualforce-unable-to-display-any-currency-field-if-advanced/td-p/136824/highlight/true/page/2
This is a painful way to fix things and additionally means writing more Test code for a controller. Surely a currency datatype should be fully supported for all currencies on a platform?