List<tempcon1> listoftemp;
CheckContactController chk = new CheckContactController();
public List<tempcon1> getconValues() {
listoftemp = new List<tempcon1>();
for (Temporary_contact__c temporary: [
SELECT
Id,
Name,
First_Name__c,
Last_Name__c,
Email__c,
Contact_list__c
FROM Temporary_contact__c
ORDER BY createddate desc
]) {
listoftemp.add(new tempcon1(temporary));
condetails = chk.Contactdetails(temporary.Xmldata__c);
contactlist = [
SELECT
Id,
FirstName,
LastName,
Name,
Email,
Phone,
(
SELECT First_Name__c, Last_Name__c, Contact_Mail_id__c
FROM Contact_Mail_id__r
WHERE Last_Name__c = :condetails.lastname
OR Contact_Mail_id__c = :condetails.email
)
FROM Contact
WHERE lastname = :condetails.lastname
OR (email != '' AND email = :condetails.email)
]; //got an error here
temporary.Contact_list__c = string.ValueOf(contactlist.size());
}
return listoftemp;
}
In this for the first time the loop enters,say suppose the contactlist Query consists of 5 records I'm passing them into temporary.Contact_list__c & so on....So it is displaying like wise for an individual item.
Since I got an error as Too many SOQL queries: 101.I have changed my method to
Set<String> conlstname = new Set<String>();
Set<String> conlstemail = new Set<String>();
public List<tempcon1> getconValues() {
listoftemp = new List<tempcon1>();
for (Temporary_contact__c temporary: [
SELECT
Id,
Name,
First_Name__c,
Last_Name__c,
Email__c,
Contact_list__c
FROM Temporary_contact__c
ORDER BY CreatedDate DESC
]) {
listoftemp.add(new tempcon1(temporary));
condetails = chk.Contactdetails(temporary.Xmldata__c);
conlstemail.add(condetails.email);
conlstname.add(condetails.lastname);
}
contactlist = [
SELECT
Id,
Firstname,
Lastname,
Name,
Email,
Phone,
(
SELECT
First_Name__c,
Last_Name__c,
Contact_Mail_id__c
FROM Contact_Mail_id__r
WHERE Last_Name__c IN :conlstname
OR Contact_Mail_id__c IN :conlstemail
)
FROM Contact
WHERE LastName In: conlstname
OR (email != '' AND email IN: conlstemail)
];
system.debug('contactlist contactlist ' + contactlist);
return listoftemp;
}
Here how should I pass the size for an Individual Item. I know this is not the correct way.Any ideas on this please