• Shayne0
  • NEWBIE
  • 20 Points
  • Member since 2013
  • Product

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hey All,

I'm trying to create a select option on a VF page that will allow the user to select an Email Template from a picklist.  Upon selection, I want to populate a text field with the email template ID.  I've built the selector, but can't figure out how to get the id into the text field.

VF Page:
<apex:page standardController="Touch__c" extensions="EmailTemplateSelector">
	<apex:form >
         <apex:selectList value="{!selectedTemplateId}" size="1" rendered="true">
             <apex:selectOptions value="{!myPersonalTemplateOptions}"/>
         </apex:selectList>
     </apex:form>
</apex:page>

Class
public class EmailTemplateSelector {

    private Id recordId;
    
    public String selectedTemplateId {get; set;}
    
    public EmailTemplateSelector(ApexPages.StandardController ctr) {

        recordId = ApexPages.currentPage().getParameters().get('id');
        
    }     
    
    public List<SelectOption> getMyPersonalTemplateOptions() {


        
        List<SelectOption> options = new List<SelectOption>();
        for (EmailTemplate t : [
            select Id,Name 
            from EmailTemplate]) {
                options.add(new SelectOption(t.Id,t.Name));
            }
        system.debug(options);
        return options;
        


        
    }
    
    public void updateTouch(String[] selectedTemplateId){

        For(Touch__c touch : [select id from Touch__c where id =: recordId]){
         
            For(EmailTemplate e : [select id from EmailTemplate where id IN: selectedTemplateId]){

            touch.Email_Template_ID__c = e.id;
            update touch;
            system.debug(selectedTemplateId);
            system.debug(e);
            }

            //return null;


        }
        
    }
    
}

 
Hello,

I'd like to write an Apex Class to use as a Post Install Script for a managed package.  The objective would be to use the class to create sample/default data whenever the package is installed.  Does anyone have an example of how this might be done?

Thanks!

I'm creating a customized button. The Query is a nested one as follows:

 

var primaryContact = sforce.connection.query("SELECT Account.Name, (SELECT Contact.FirstName FROM OpportunityContactRoles) FROM Opportunity WHERE Id='{!Opportunity.Id}'");

 

The query is a success. But I'm not able to access Contact.FirstName using sforce.QueryResultIterator. The error read: "Can not read property FirstName of undefined". My code is:

 

if ( primaryContact .size > 0) {
     var it = new sforce.QueryResultIterator(primaryContact );
     while (it.hasNext()) {
               var query = it.next();
               var firstName = query.OpportunityContactRoles.Contact.FirstName;
     }
}

 

Please let me know how to access FirstName using the sforce.QueryResultIterator.

Hey All,

I'm trying to create a select option on a VF page that will allow the user to select an Email Template from a picklist.  Upon selection, I want to populate a text field with the email template ID.  I've built the selector, but can't figure out how to get the id into the text field.

VF Page:
<apex:page standardController="Touch__c" extensions="EmailTemplateSelector">
	<apex:form >
         <apex:selectList value="{!selectedTemplateId}" size="1" rendered="true">
             <apex:selectOptions value="{!myPersonalTemplateOptions}"/>
         </apex:selectList>
     </apex:form>
</apex:page>

Class
public class EmailTemplateSelector {

    private Id recordId;
    
    public String selectedTemplateId {get; set;}
    
    public EmailTemplateSelector(ApexPages.StandardController ctr) {

        recordId = ApexPages.currentPage().getParameters().get('id');
        
    }     
    
    public List<SelectOption> getMyPersonalTemplateOptions() {


        
        List<SelectOption> options = new List<SelectOption>();
        for (EmailTemplate t : [
            select Id,Name 
            from EmailTemplate]) {
                options.add(new SelectOption(t.Id,t.Name));
            }
        system.debug(options);
        return options;
        


        
    }
    
    public void updateTouch(String[] selectedTemplateId){

        For(Touch__c touch : [select id from Touch__c where id =: recordId]){
         
            For(EmailTemplate e : [select id from EmailTemplate where id IN: selectedTemplateId]){

            touch.Email_Template_ID__c = e.id;
            update touch;
            system.debug(selectedTemplateId);
            system.debug(e);
            }

            //return null;


        }
        
    }
    
}

 
Hello,

I'd like to write an Apex Class to use as a Post Install Script for a managed package.  The objective would be to use the class to create sample/default data whenever the package is installed.  Does anyone have an example of how this might be done?

Thanks!