You need to sign in to do that
Don't have an account?
Email Tempate, VF Component, and Controller
I am trying to set up an email template that uses a component which references a class. I think I'm very close, but I can't seem to pass the argument to the class. Any help would be greatly appreciated.
If I replace :partnerid in the class with an actual string value....it all works fine.
The Class
//```````````````````````````````````````````````````````````````
public with sharing class findPartnerAccountsByPartnerName {
private final List<Account> accounts;
public String partnerid {
get; set;
}
public findPartnerAccountsByPartnerName() {
accounts = [select Name,ShippingCity,ShippingState,ShippingPostalCode,
Type,industry,ShippingCountry,partner_id__c from Account
where Partner_ID__c = :partnerid
and Inactive_Account__c = False
order by type asc, Name asc];
}
public List<Account> getAccounts() {
return accounts;
}
}
//````````````````````````````````````````````````````````````````
The Component (snipet)
<apex:component controller="findPartnerAccountsByPartnerName" access="global">
<apex:attribute name="mypartnerid"
description="This is the ID of the partner."
type="String" assignTo="{!partnerid}" />
<apex:dataTable cellspacing="5" value="{!Accounts}" var="a">
//````````````````````````````````````````````````````````````````
The Email Template
<messaging:emailTemplate subject="Current List of Tactician Customers and Prospects"
recipientType="Contact" relatedToType="Account"
>
<messaging:htmlEmailBody >
<html>
<body >
<p>Below is a list of ...</p>
<c:PartnerCustomers mypartnerid="{!relatedTo.PartnerConnect__c}">
</c:PartnerCustomers>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Hey,
Your constructor is always being called before your getter is set (it's an order of execution thing). Try this instead:
public with sharing class findPartnerAccountsByPartnerName {
public List<Account> accounts{
get{
if(accounts == null){
accounts = [select Name,ShippingCity,ShippingState,ShippingPostalCode ,
Type,industry,ShippingCountry,partner_id__c from Account
where Partner_ID__c = :partnerid
and Inactive_Account__c = False
order by type asc, Name asc];
}
return accounts;
} set; }
public String partnerid {
get; set;
}
public findPartnerAccountsByPartnerName() {
}
}
All Answers
Hey,
Your constructor is always being called before your getter is set (it's an order of execution thing). Try this instead:
public with sharing class findPartnerAccountsByPartnerName {
public List<Account> accounts{
get{
if(accounts == null){
accounts = [select Name,ShippingCity,ShippingState,ShippingPostalCode ,
Type,industry,ShippingCountry,partner_id__c from Account
where Partner_ID__c = :partnerid
and Inactive_Account__c = False
order by type asc, Name asc];
}
return accounts;
} set; }
public String partnerid {
get; set;
}
public findPartnerAccountsByPartnerName() {
}
}
weznolte!
Thank you so much. I wouldn't have come up with that. Your solution worked perfectly.
Thanks for your time, I really appreciate it.
p-