Skip to main content
Tweeted twitter.com/StackSalesforce/status/1535411504132067328
deleted 103 characters in body
Source Link
PartOfTheOhana
  • 10.6k
  • 15
  • 95
  • 182

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

EDIT- Code:

Apex Class

    public with sharing class BenefitChecklistEmailTemplateHelper {
        public list <Benefit_Checklist__c> checklists;
        public String oppId {get; set;}
        
        public BenefitChecklistEmailTemplateHelper(){
            system.debug('oppid :' +oppId);
            this.checklists = [select id, name from Benefit_Checklist__c where Opportunity__c = :oppId];
            getChecklists();
        }   
        public list<Benefit_Checklist__c> getChecklists(){
             return checklists;
        }
    }

Custom component

    <apex:component controller="BenefitChecklistEmailTemplateHelper" access="global">
    <apex:attribute id="oppId" assignTo="{!oppId}" name="opportunityIDFromEmail" type="ID" description="The Opporunity's SF ID"/>    
       <table border="0" >
             <tr>
                 <apex:repeat var="c" value="{!Checklists}">
                    <tr>
                        <td><a href="https://na1.salesforce.com/{!c.id}">View</a> </td>
                        <td class="sub_section_label">Checklist Name</td><td class="sub_section_data">: {!c.id}</td>
                    </tr>
                </apex:repeat>   
            </tr>              
        </table>
    </apex:component>

Email Template

    <c.BenefitChecklistEmailTemplateHelper opportunityIDFromEmail="{!relatedTo}"/>

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

EDIT- Code:

Apex Class

    public with sharing class BenefitChecklistEmailTemplateHelper {
        public list <Benefit_Checklist__c> checklists;
        public String oppId {get; set;}
        
        public BenefitChecklistEmailTemplateHelper(){
            system.debug('oppid :' +oppId);
            this.checklists = [select id, name from Benefit_Checklist__c where Opportunity__c = :oppId];
            getChecklists();
        }   
        public list<Benefit_Checklist__c> getChecklists(){
             return checklists;
        }
    }

Custom component

    <apex:component controller="BenefitChecklistEmailTemplateHelper" access="global">
    <apex:attribute id="oppId" assignTo="{!oppId}" name="opportunityIDFromEmail" type="ID" description="The Opporunity's SF ID"/>    
       <table border="0" >
             <tr>
                 <apex:repeat var="c" value="{!Checklists}">
                    <tr>
                        <td><a href="https://na1.salesforce.com/{!c.id}">View</a> </td>
                        <td class="sub_section_label">Checklist Name</td><td class="sub_section_data">: {!c.id}</td>
                    </tr>
                </apex:repeat>   
            </tr>              
        </table>
    </apex:component>

Email Template

    <c.BenefitChecklistEmailTemplateHelper opportunityIDFromEmail="{!relatedTo}"/>

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

EDIT- Code:

Apex Class

    public with sharing class BenefitChecklistEmailTemplateHelper {
        public list <Benefit_Checklist__c> checklists;
        public String oppId {get; set;}
        
        public BenefitChecklistEmailTemplateHelper(){
            system.debug('oppid :' +oppId);
            this.checklists = [select id, name from Benefit_Checklist__c where Opportunity__c = :oppId];
            
        }   
}

Custom component

    <apex:component controller="BenefitChecklistEmailTemplateHelper" access="global">
    <apex:attribute id="oppId" assignTo="{!oppId}" name="opportunityIDFromEmail" type="ID" description="The Opporunity's SF ID"/>    
       <table border="0" >
             <tr>
                 <apex:repeat var="c" value="{!Checklists}">
                    <tr>
                        <td><a href="https://na1.salesforce.com/{!c.id}">View</a> </td>
                        <td class="sub_section_label">Checklist Name</td><td class="sub_section_data">: {!c.id}</td>
                    </tr>
                </apex:repeat>   
            </tr>              
        </table>
    </apex:component>

Email Template

    <c.BenefitChecklistEmailTemplateHelper opportunityIDFromEmail="{!relatedTo}"/>
added 1216 characters in body
Source Link
PartOfTheOhana
  • 10.6k
  • 15
  • 95
  • 182

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

EDIT- Code:

Apex Class

    public with sharing class BenefitChecklistEmailTemplateHelper {
        public list <Benefit_Checklist__c> checklists;
        public String oppId {get; set;}
        
        public BenefitChecklistEmailTemplateHelper(){
            system.debug('oppid :' +oppId);
            this.checklists = [select id, name from Benefit_Checklist__c where Opportunity__c = :oppId];
            getChecklists();
        }   
        public list<Benefit_Checklist__c> getChecklists(){
             return checklists;
        }
    }

Custom component

    <apex:component controller="BenefitChecklistEmailTemplateHelper" access="global">
    <apex:attribute id="oppId" assignTo="{!oppId}" name="opportunityIDFromEmail" type="ID" description="The Opporunity's SF ID"/>    
       <table border="0" >
             <tr>
                 <apex:repeat var="c" value="{!Checklists}">
                    <tr>
                        <td><a href="https://na1.salesforce.com/{!c.id}">View</a> </td>
                        <td class="sub_section_label">Checklist Name</td><td class="sub_section_data">: {!c.id}</td>
                    </tr>
                </apex:repeat>   
            </tr>              
        </table>
    </apex:component>

Email Template

    <c.BenefitChecklistEmailTemplateHelper opportunityIDFromEmail="{!relatedTo}"/>

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

EDIT- Code:

Apex Class

    public with sharing class BenefitChecklistEmailTemplateHelper {
        public list <Benefit_Checklist__c> checklists;
        public String oppId {get; set;}
        
        public BenefitChecklistEmailTemplateHelper(){
            system.debug('oppid :' +oppId);
            this.checklists = [select id, name from Benefit_Checklist__c where Opportunity__c = :oppId];
            getChecklists();
        }   
        public list<Benefit_Checklist__c> getChecklists(){
             return checklists;
        }
    }

Custom component

    <apex:component controller="BenefitChecklistEmailTemplateHelper" access="global">
    <apex:attribute id="oppId" assignTo="{!oppId}" name="opportunityIDFromEmail" type="ID" description="The Opporunity's SF ID"/>    
       <table border="0" >
             <tr>
                 <apex:repeat var="c" value="{!Checklists}">
                    <tr>
                        <td><a href="https://na1.salesforce.com/{!c.id}">View</a> </td>
                        <td class="sub_section_label">Checklist Name</td><td class="sub_section_data">: {!c.id}</td>
                    </tr>
                </apex:repeat>   
            </tr>              
        </table>
    </apex:component>

Email Template

    <c.BenefitChecklistEmailTemplateHelper opportunityIDFromEmail="{!relatedTo}"/>
deleted 1318 characters in body
Source Link
PartOfTheOhana
  • 10.6k
  • 15
  • 95
  • 182

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

UPDATED WITH CODE:

From email template

    <c.ChecklistEmailTemplateHelperVF opportunityIDFromEmail="{!relatedTo.Id}"/>

    

From Custom Component
<apex:component controller=ChecklistEmailTemplateHelper" access="global">

    <apex:attribute id="oppId" assignTo="{!oppId}" name="opportunityIDFromEmail" type="ID" description="The Opporunity's SF ID"/>    
         <apex:repeat var="c" value="{!Checklists}">
            <tr>
                <td><a href="https://na1.salesforce.com/{!c.id}">View</a> | 
                <a href="https://na1.salesforce.com/{!c.id}/e">Edit</a></td>

            <td class="sub_section_label">Checklist Name</td><td class="sub_section_data">: {!c.name}</td></tr>
            <td class="sub_section_label">Any Changes</td><td class="sub_section_data">: {!c.Any_changes__c}</td></tr>
                            
            </tr>
        </apex:repeat>           
    </apex:component>

From Apex

    public with sharing class ChecklistEmailTemplateHelper {
        public list <Checklist__c> checklists;
        public String oppId {get; set;}
        
        public ChecklistEmailTemplateHelper(){
            system.debug('oppid :' +oppId);
            this.checklists = [select id, name, anychanges__c from Checklist__c where Opportunity__c = :oppId];
        }   
        public list<Checklist__c> getChecklists(){
             return checklists;
        }
    }                   

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?

UPDATED WITH CODE:

From email template

    <c.ChecklistEmailTemplateHelperVF opportunityIDFromEmail="{!relatedTo.Id}"/>

    

From Custom Component
<apex:component controller=ChecklistEmailTemplateHelper" access="global">

    <apex:attribute id="oppId" assignTo="{!oppId}" name="opportunityIDFromEmail" type="ID" description="The Opporunity's SF ID"/>    
         <apex:repeat var="c" value="{!Checklists}">
            <tr>
                <td><a href="https://na1.salesforce.com/{!c.id}">View</a> | 
                <a href="https://na1.salesforce.com/{!c.id}/e">Edit</a></td>

            <td class="sub_section_label">Checklist Name</td><td class="sub_section_data">: {!c.name}</td></tr>
            <td class="sub_section_label">Any Changes</td><td class="sub_section_data">: {!c.Any_changes__c}</td></tr>
                            
            </tr>
        </apex:repeat>           
    </apex:component>

From Apex

    public with sharing class ChecklistEmailTemplateHelper {
        public list <Checklist__c> checklists;
        public String oppId {get; set;}
        
        public ChecklistEmailTemplateHelper(){
            system.debug('oppid :' +oppId);
            this.checklists = [select id, name, anychanges__c from Checklist__c where Opportunity__c = :oppId];
        }   
        public list<Checklist__c> getChecklists(){
             return checklists;
        }
    }                   

setup:

Opportunities are related in a MDR to children__c object. When my opp reaches a stage, an email alert (via workflow) gets sent out with the opp info. I want to include a list of urls for the children record related to that master opp. I did some reading- and it looks like custom components do the trick.

questions:

  1. is this the right approach?
  2. how do i pass params to the custom compoenent from the email template?
added 2 characters in body
Source Link
PartOfTheOhana
  • 10.6k
  • 15
  • 95
  • 182
Loading
added 1320 characters in body
Source Link
PartOfTheOhana
  • 10.6k
  • 15
  • 95
  • 182
Loading
deleted 90 characters in body
Source Link
PartOfTheOhana
  • 10.6k
  • 15
  • 95
  • 182
Loading
Source Link
PartOfTheOhana
  • 10.6k
  • 15
  • 95
  • 182
Loading