0

I was wondering if it is possible to pull in data from a non-relatedTo object into a visualforce email template.

For example, I have a recipient as a "Contact" object and the relatedTo object is the "Account" they are associated with (a physical building in this case). The building may have access to different services (aka a checkbox for verizonEnabled, directTVEnabled etc.). I'd like to display data from the particular vendor objects, say Verizon, in the email based on the different services that have been checked. Couldn't find a way to make the references. Any help would be much appreciated!

Thanks!!!

1 Answer 1

1

Yes, it's possible to pull in any arbitrary record... But the system won't make it easy for you.

First, you need to create a Visualforce component:

<apex:component controller="vendorComponentController">
  <apex:attribute name="vendorName" assignTo="{!vendorName}" required="true" 
        description="The name of the vendor to show" />
    ......
</apex:component>

You'll need a controller to query the vendor record, then display whatever you'd like to display.

Overall, it's a very non-trivial solution, but possible.

As an alternative, consider simply linking the vendor records to the account (e.g. by using a custom object called "Account Vendors" that looks the two). For the most part, as long as you have a direct relationship between the vendor and account, you can reference the records without resorting to writing code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .