Skip to main content
added 624 characters in body
Source Link
cropredy
  • 73.3k
  • 8
  • 128
  • 283

You have a couple of issues here:

  1. Constructor public SalesReportExtension(ApexPages.StandardController controller) will never be called since you stated this is a custom controller (although I'm not so sure about this given your assertion that the VF page works fine).
  2. When used in a VF Component, the constructor public SalesReportExtension() is called before the setter for the component's assignTo="{!accountId}"

Hence, the SOQL select statement in the constructor public SalesReportExtension() will not have a value for accountId as the list accountIds has only a single null element.

A handy reference is the VF Developer's Guide Order of Execution

Update

What triggers the email template to be rendered? Is it a workflow/approval process w/ email alert? if yes - then the record being triggered will implicitly be bound to relatedToType.

I believe that sending an email from 'Send and Email' button on the Account's related lists will also implicitly bind the account to relatedToType.

If using apex to send the email via some controller action or webservice, then the value of setWhatid(..) does the binding.

When you test/preview in the Email template editor, you have to provide an Account in the popup dialog - this also does the binding.

You have a couple of issues here:

  1. Constructor public SalesReportExtension(ApexPages.StandardController controller) will never be called since you stated this is a custom controller (although I'm not so sure about this given your assertion that the VF page works fine).
  2. When used in a VF Component, the constructor public SalesReportExtension() is called before the setter for the component's assignTo="{!accountId}"

Hence, the SOQL select statement in the constructor public SalesReportExtension() will not have a value for accountId as the list accountIds has only a single null element.

A handy reference is the VF Developer's Guide Order of Execution

You have a couple of issues here:

  1. Constructor public SalesReportExtension(ApexPages.StandardController controller) will never be called since you stated this is a custom controller (although I'm not so sure about this given your assertion that the VF page works fine).
  2. When used in a VF Component, the constructor public SalesReportExtension() is called before the setter for the component's assignTo="{!accountId}"

Hence, the SOQL select statement in the constructor public SalesReportExtension() will not have a value for accountId as the list accountIds has only a single null element.

A handy reference is the VF Developer's Guide Order of Execution

Update

What triggers the email template to be rendered? Is it a workflow/approval process w/ email alert? if yes - then the record being triggered will implicitly be bound to relatedToType.

I believe that sending an email from 'Send and Email' button on the Account's related lists will also implicitly bind the account to relatedToType.

If using apex to send the email via some controller action or webservice, then the value of setWhatid(..) does the binding.

When you test/preview in the Email template editor, you have to provide an Account in the popup dialog - this also does the binding.

added 88 characters in body
Source Link
cropredy
  • 73.3k
  • 8
  • 128
  • 283

You have a couple of issues here:

  1. Constructor public SalesReportExtension(ApexPages.StandardController controller) will never be called since you stated this is a custom controller (although I'm not so sure about this given your assertion that the VF page works fine).
  2. When used in a VF Component, the constructor public SalesReportExtension() is called before the setter for the component's assignTo="{!accountId}"

Hence, the SOQL select statement in the constructor public SalesReportExtension() will not have a value for accountId as the list accountIds has only a single null element.

A handy reference is the VF Developer's Guide Order of Execution

You have a couple of issues here:

  1. Constructor public SalesReportExtension(ApexPages.StandardController controller) will never be called since you stated this is a custom controller
  2. When used in a VF Component, the constructor public SalesReportExtension() is called before the setter for the component's assignTo="{!accountId}"

Hence, the SOQL select statement in the constructor public SalesReportExtension() will not have a value for accountId as the list accountIds has only a single null element.

A handy reference is the VF Developer's Guide Order of Execution

You have a couple of issues here:

  1. Constructor public SalesReportExtension(ApexPages.StandardController controller) will never be called since you stated this is a custom controller (although I'm not so sure about this given your assertion that the VF page works fine).
  2. When used in a VF Component, the constructor public SalesReportExtension() is called before the setter for the component's assignTo="{!accountId}"

Hence, the SOQL select statement in the constructor public SalesReportExtension() will not have a value for accountId as the list accountIds has only a single null element.

A handy reference is the VF Developer's Guide Order of Execution

Source Link
cropredy
  • 73.3k
  • 8
  • 128
  • 283

You have a couple of issues here:

  1. Constructor public SalesReportExtension(ApexPages.StandardController controller) will never be called since you stated this is a custom controller
  2. When used in a VF Component, the constructor public SalesReportExtension() is called before the setter for the component's assignTo="{!accountId}"

Hence, the SOQL select statement in the constructor public SalesReportExtension() will not have a value for accountId as the list accountIds has only a single null element.

A handy reference is the VF Developer's Guide Order of Execution