-
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
Guidelines to Pick the Best Salesforce Development Companies
The traditional methods of running a business have gone obsolete in today’s fast-paced world of growing eCommerce and globalization. Companies just starting their journey are…
How to Use Salesforce Chatter Better?
Here are 3 main STEPS, by which you can use SALESFORCE chatter more efficiently. Take a look… STEP 1: Follow relevant people and data Keep…
Why Having a Salesforce Admin Online Training an Excellent Idea?
In today's job market, professional courses Salesforce administration & development course is the assets you can have. It'll add value to your resume and also…
Popular Salesforce Videos
How to Execute a SOQL Query in POSTMAN?
Watch this video to learn how to execute a SOQL Query in POSTMAN. If you have any doubts or questions, let us know in the…
What are Apps and Tabs in Salesforce?
In this video, Shrey is not only teaching but also demonstrating to you "What are Apps and Tabs in Salesforce?" You will be learning: 1.…
What Is Salesforce and Why Is It So Good?
Salesforce is by far the most popular CRM tool for sales, support, and marketing teams worldwide. But what exactly is a CRM and why do…
Popular Salesforce Infographics
What to expect with a Salesforce project?
It is important to note that one person can fulfill more than one role (typically in smaller projects) but these roles do need to be…
Impact of Salesforce
Salesforce is no doubt is one of the boldest CRM on the cloud in the world. This infographic helps you scan through all the vital…
See How Building Apps on Salesforce Has Tremendous ROI
The pressure that businesses today are under to reduce costs, improve agility, and deliver better results is no joke. Couple that with rapidly evolving technology…