-
Why selected contact not showing in EmailDetail page?
In my page after selecting sendEmail Button, My page is redirecting to EmailDetail page
But In EmailDetail page selected contact is not showing.
Here is code
<apex:page controller="SearchRecords" showHeader="false" sidebar="false" >
<apex:form id="frm">
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecord}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="{!display}" />
<apex:actionSupport event="onclick" action="{!newClick}" reRender="conSection" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.Phone}"/>
</apex:pageBlocktable>
</apex:pageBlockSection><apex:outputPanel id="conSection">
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" >
<apex:commandButton value="Send Email" action="{!SendEmail}"/>
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled="{!disable}"/>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>public class SearchRecords {
public boolean display{get;set;}
public boolean disable{get;set;}
public String AccId{get;set;}
public string getstring{get;set;}
public string selectedvalie{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
public list<Attachment> AttachmentList{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=3;
public contact con{get;set;}
public Attachment Att{get;set;}
public string Body{get;set;}
public string Subject{get;set;}
public string selectAttachment{get;set;}
public boolean Attc{get;set;}
public boolean Docu{get;set;}
public boolean SysFil{get;set;}
public List<WrapperClass> listWrapper {get;set;}
public List<WrapperClass> listWrapper1 {get;set;}
public void searchRecord(){
display=False;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public void newClick(){
disable=false;
LimitSize=3;
OffsetSize=0;
showContact();
}
public void showContact(){
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
if(conlist!=NULL){
totalRecs = conlist.size();
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public pageReference PrintDetail(){
listWrapper1=new list<WrapperClass>();
for(WrapperClass wr: listWrapper){
if(wr.checked==true)
listWrapper1.add(wr);
}
pageReference acctPage = new pageReference('/Apex/printContactDetail');
return acctPage;
}public pageReference SendEmail(){
listWrapper1=new list<WrapperClass>();
String str='';
for(WrapperClass wr: listWrapper){
if(wr.checked==true){
listWrapper1.add(wr);
str+=wr.con.id+',';
}
system.debug('====>listWrapper1'+listWrapper1);
}
str=str.removeEnd(',');
pageReference EmailPage = new pageReference('/Apex/EmailDetail?id='+str);
emailPage.setRedirect(true);
return EmailPage;
}
public pageReference AddFile(){
String str=ApexPages.currentPage().getParameters().get('id');
PageReference acctPage = new pageReference('/Apex/AttachmentPage?id='+str);
return acctPage;
}
set<id> contactId=new set<Id>();public void Attachment(){
String str1=ApexPages.currentPage().getParameters().get('id');
system.debug('---line81'+str1);
for(string st:str1.split(',')){
contactid.add(st);
}
AttachmentList=[select Id,Name,Body,BodyLength,ContentType,ParentId from Attachment where ParentId IN:contactId];
system.debug('AttachmentList'+AttachmentList);
}
public void HideShow(){
system.debug('selectAttachment'+selectAttachment);
if(selectAttachment=='Attachment'){
Attc=True;
Docu=False;
SysFil=False;
Attachment();
}
else if(selectAttachment=='Document'){
Attc=False;
Docu=True;
SysFil=False;
}
else if(selectAttachment=='System File'){
Attc=False;
Docu=False;
SysFil=True;
}
}
public pageReference Send(){
return null;
}
public pageReference Cancel(){
return null;
}
public void FirstPage(){
disable=false;
OffsetSize = 0;
showContact();
}
public void previous(){
disable=false;
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
showContact();
}
public void LastPage(){
disable=true;
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
showContact();}
public boolean getprev(){
if(OffsetSize == 0)
return true;
else
return false;}
public boolean getnxt(){
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}public pageReference Save(){
return null;
}
public class WrapperClass {
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con) {
this.con=con;
checked=false;
}
}
}
EmailDetail page
<apex:page controller="SearchRecords" showHeader="false" sidebar="false">
<script>
function openPopup(){
window.open('/apex/AttachmentPage','mywindow','width=600,height=400');
}
</script>
<apex:form >
<apex:pageBlock title="Send Email To Selected Contacts">
<div align="Middle">
<apex:commandButton value="Send" action="{!Send}" />
<apex:commandButton value="Add File" onclick="openPopup();return false;"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</div>
<apex:pageBlockSection title="Email" columns="1">
<apex:repeat value="{!listWrapper1}" var="wrap">
To:<apex:outputfield value="{!wrap.con.Name}" />
</apex:repeat>
<div class = "requiredInput">
Subject<div class = "requiredBlock"></div>
<apex:inputText title="Subject" required="true"/>
</div>
<apex:inputtextarea label="Body" richtext="true" value="{!Body}" cols="50" rows="15"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Log In to reply.
Popular Salesforce Blogs

Build A Strong and Powerful Community and Go Beyond Your Dreams
Over the last few weeks, we had relished bringing out the outstanding features of Sales Cloud and Service Cloud that will be released in Spring ‘20. Sales, Service, and…

Why Do You Need Salesforce CRM Support in 2024?
In the fast-paced world of business, nurturing strong relationships with customers is the cornerstone of success. That's where Customer Relationship Management (CRM) platforms like Salesforce…

Introducing Salesforce Blockchain: World’s No.1 CRM Moves into Blockchain with its own Platform
Salesforce just got done with TrailheaDX 2019 this weekend. Algoworks was at TDX19 too, and oh boy, did we have fun! There was a bunch…
Popular Salesforce Videos
Survival Kit for Beginner Salesforce Developers - 1
Are you a developer just starting out with Salesforce? Are you an admin looking to get into development? Join us to learn a few easy,…
Welcome to the New World of Data Collection | Salesforce
Secure data collection built for your needs. With FormAssembly, your organization can streamline outdated processes and power important business initiatives. Click the link below to…
Improve Your Front and Backend Team Collaboration With Sinergify | Salesforce CRM
Businesses that use Salesforce CRM and Atlassian Jira separately face a lack of team collaboration, inconsistent customer data, slower case resolution, and reduced agent productivity.…
Popular Salesforce Infographics

Top Benefits of Integrating Salesforce and NetSuite
Salesforce, on the one hand, is the world’s number cloud-based CRM. NetSuite, on the other hand, is one of the best ERP systems. And when…

Enhance Customer Experience With Salesforce
Salesforce Makes Personalized, Consistent Digital Customer Experience a Reality. Salesforce, widely recognized as the leader in business CRM, gives organizations the tools they need to…

Introduction to The Salesforce Architecture
Have you ever wondered what is so special about Salesforce? How does it manage to accomplish so much in such less time? Well, the secret…