Can we use other object's
field in VF template
, if yes then how?
Please suggest.
2 Answers
Yes, you can use another object field using a component and for this you need to make a apex controller.
You can do that by creating a Visualforce Email Template with a Custom Controller.
Here are the steps:
- Create a Custom Controller Apex class.
- Create a Custom Component that has its controller attribute set to the class created in step #1.
- Create a Visualforce Email Template that includes the Custom Component created in Step #2.
This is outlined with an example in the documentation Using Custom Controllers within Visualforce Email Templates.