You need to sign in to do that
Don't have an account?
hideawayguy
standard controller getting the wrong id in email template from apex page
hi i'm pretty new to visualforce, i'm sure you'll be able to tell. i'm creating a visualforce email template and i need to pull in an apex page that pulls data from a custom object. the code from the apex page looks like this:
<apex:page standardController="Inquiry__c">
{!Inquiry__c.Name}
</apex:page>
that's being called into the visual force template with an apex include statement.
i ge this error when trying to select the template when trying to send the actual email though:
Try this.And, mark this as SOLVED if it resolved..
All the best.
Don't forget to mark this as SOLVED if it resolved.
hi thank you for the reply. i've added the code you've suggested as follows:
<apex:page standardController="Inquiry__c" recordSetVar="Inquiries">
<apex:pageBlock title="Emails">
<apex:pageBlockSection>
<apex:pageBlockTable value="{!Inquiries}" var="I">
<apex:column value="{!I.Name}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
when i select the email template i get this error...
Try the below code in between <messaging:emailTemplate> i.e. outermost tags.
since you have assigned "Inquiry__c" to "relatedToType" attribute in "<apex:emailTemplate>" tag, use "relatedTo" variable to point to your custom object i.e. "Inquiry__c" . That's it.
Also read the below hints which are useful for your future career.
Actually, the Visual Force code I have provided you in my first replay is to display all the records of Inquiry__c object in the visual Force page using standardController. Please keep in mind you are going to be in need of that scenario in the future. ?and also study the standard Functions of the standardController eg Save, next, previous, first, last, quickSave etc.
Waiting for your replay
PLEASE MARK IT AS SOLVED once you got the resuil\t.
Feel free for further communication,..
All the best.
-----
Force.com Advance Development Trainer
Force.com Sites Implementations Expert
hello again and thanks for the tip on displaying all records for the future! however, adding the variable to the apex page like this...
<apex:page standardController="Inquiry__c">
{!relatedTo.Name}
</apex:page>
produces this error....
Error: Unknown property 'Inquiry__cStandardController.Name'
i'm guessing you were talking about adding relatedTo.Name to the email template itself and not calling it in through an apex page??? is that correct?
i know it works in the visualfoce email template itself. i need to move it out of the template itself and call it in from an apex page or a component or maybe there is something out there that i am unaware of. that's where i'm running into to the big trouble, i can't seem to get the single object relationship passed into the page/component (i've tried with components too) from the visual force email template. is that not possible? seems like it would be...
thanks for you help.
why to use <apex:page> components, please go through previous reply carefully and implement as it is, no need of including page again, becausse itself it is vf email template.
revert after checkig..
the reason i want to use a component or page to is to maintain ONE file that handles the display code that can be called from multiple visual force templates. the email that is being generated contains a lot of information, images links back to pages on client websites etc... that data is being pulled from an individual inquiry object, and other data is pulled from a related object that is has a master detail field that links the two together.
we have multiple clients that will use this template with over a dozen template emails per client. the display will be identical in form, but unique in message, content, images, links etc... i'm trying to avoid having to maintain and update hundreds of email templates.....
does that make sense?
call display code wrapper opening file
call messaging data from inquiry and related object
call display code ending file
this would allow me to generate multiple vf templates that use the same display output. maybe it's not possible and i have to look into other alternatives, but the goal is to not maintain hundreds of lengthy html emails.
thanks again for your help!