-
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

Illustrations in Salesforce Lightning Experience
An illustration is an image or a diagram that helps make something clear. Inline texts work with illustrations to communicate a state in a more…

Why Your Business Needs to Integrate Salesforce with Jira - Top 6 Reasons
For every business, the customer is God! To prevent their fury, they leave no stone unturned to increase the smile on their face. For that,…

What is Dynamic Dashboard? | All You Need to Know
Dynamic Dashboard is a type of dashboard that allows users to personalize their view by interacting with the dashboard components. It enables users to modify…
Popular Salesforce Videos
How Leadership Skills Helps to Shape Your Career? | Salesforce Learning
Leadership is an important skill to have because a good leader is able to bring out the best abilities in his/her team members and motivate…
Replicate Salesforce Data in Real-Time with Change Data Capture
In this video, we will see how to replicate Salesforce data Migrate your batch processing, scheduled ETL, and nightly workloads to event-driven, real-time integrations using…
How to import data from Sage ERP to Salesforce - Part 1
Greytrix offers GUMU™ integration for Salesforce with Sage ERP systems - a best-of-breed solution for organizations to enhance their customer interaction. With Salesforce and Sage…
Popular Salesforce Infographics

How Salesforce Improves User Experience Through Hyper-Personalization?
Personalized service has become an imperative part for any business to succeed in the cut-throat competitive market. 66% of people want companies to understand their…

Salesforce Operations/Demographics
Salesforce, the world’s No. 1 CRM Company, has significantly changed the way how business software is delivered and used. Salesforce has found the perfect way…

Why Do Business Move To Salesforce?
Salesforce Improves Customer Data Quality & Management – One of the core functions of all CRMs is data management about customers. Salesforce delivers in this…