You need to sign in to do that
Don't have an account?
Accessing Custom Component Inside Installed Managed Package from VF Email Template
We have a managed package that includes a Visual Force Custom Component that is accessed from a Visual Force Email Template. We have no problem accessing the component from a packaged VF Email Template. However, post install, I don't know how to create a new VF Email Template that can reference the packaged VF Custom Component.
We get this error:
Error: Component c:ourCustomComponent does not exist
Our VF Email template looks like this:
<messaging:emailTemplate subject="Past Due Balance" recipientType="Contact" relatedToType="ournamespace__OurCustomObject__c">
<messaging:htmlEmailBody >
<br/><apex:image value="{!relatedTo.ournamespace__our_field1__c}" />
<br/><br/><br/>Dear {!recipient.firstName}:
<br/><br/>This is to inform you that you owe: <apex:outputfield value="{!relatedTo.ournamespace__our_field2__c}"/>
</messaging:htmlEmailBody>
<messaging:attachment renderAs="application/vnd.ms-excel" filename="invoices" >
<c:ourCustomComponet ourId="{!relatedTo.Id}"/>
</messaging:attachment>
</messaging:emailTemplate>
I saw another posting related to using a packaged custom component inside of a Visual Force page that suggested replacing the "c:" with "namespace:" in front of the component name, but this does not work. Generates this error:
Error: Unknown component ournamespace:ourCustomComponent
Surely, there must be a way to use a packaged component from an email template. Has anyone enountered this problem and know of a good solution?
Thanks,
Tom
Adding access="global" to the <apex:attribute> tags in my component fixed it. I already had global on the component itself.
So these seem to be the things to keep in mind if you package a custom component and want to use in an installed org:
1) set access="global" in the <apex:component ...> tag of the component.
2) set access="global" in any <apex:attribute...> tag included in the component.
3) reference the component with namespace:componentName, rather than c:componentName
All Answers
How is the component defined? Is it global?
The component is global. However, I realize that it has an attribute that is not global. I have changed that and am uploading my new package as I write this reply. I let you know what happens.
Adding access="global" to the <apex:attribute> tags in my component fixed it. I already had global on the component itself.
So these seem to be the things to keep in mind if you package a custom component and want to use in an installed org:
1) set access="global" in the <apex:component ...> tag of the component.
2) set access="global" in any <apex:attribute...> tag included in the component.
3) reference the component with namespace:componentName, rather than c:componentName
Sounds like the error handling was less than ideal.
Note it should be possible to have a public attribute on a component, but it can be used only by pages/components in the same package. (And therefore, it cannot be a "required" attribute).