Can we use other object's field in VF template, if yes then how? Please suggest.


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:

  1. Create a Custom Controller Apex class.
  2. Create a Custom Component that has its controller attribute set to the class created in step #1.
  3. 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.

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.