You need to sign in to do that
Don't have an account?
Shayne0
Select Option to Update a Record
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:
Class
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; } } }
Try this page
This page demonstate you that template id passed to selectedTemplateId property.
I recomended you avoid soql and dml for loop
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks,
Alex
All Answers
Try this page
This page demonstate you that template id passed to selectedTemplateId property.
I recomended you avoid soql and dml for loop
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks,
Alex