You need to sign in to do that
Don't have an account?
Rajashri
Initial term of field expression must be a concrete SObject: LIST<Lead>
Hi,
I am trying to assign the lead id but i am getting the error as Initial term of field expression must be a concrete SObject: LIST<Lead>
Can anyone Please help?
public with sharing class CampaignMemController {
public Campaign camp {get; set; }
public CampaignMemController(ApexPages.StandardController controller) {
camp = (Campaign)controller.getRecord();
}
public List<Lead> lead;
public List<Lead> leadlist = new list<Lead>();
public List<Lead> cmlist;
public List<Lead> getLead() {
if(lead == null) {
lead = [SELECT Id,Name FROM Lead];
}
return lead;
}
public List<Lead> CampaignMembers;
public List<Lead> getCampaignMembers() {
CampaignMembers=[Select Id,Name,(SELECT id, contactid FROM campaignmembers WHERE Id = :camp.Id AND LeadId != null ) from Lead WHERE Id= :lead.id ];
return CampaignMembers;
}
}
I am trying to assign the lead id but i am getting the error as Initial term of field expression must be a concrete SObject: LIST<Lead>
Can anyone Please help?
public with sharing class CampaignMemController {
public Campaign camp {get; set; }
public CampaignMemController(ApexPages.StandardController controller) {
camp = (Campaign)controller.getRecord();
}
public List<Lead> lead;
public List<Lead> leadlist = new list<Lead>();
public List<Lead> cmlist;
public List<Lead> getLead() {
if(lead == null) {
lead = [SELECT Id,Name FROM Lead];
}
return lead;
}
public List<Lead> CampaignMembers;
public List<Lead> getCampaignMembers() {
CampaignMembers=[Select Id,Name,(SELECT id, contactid FROM campaignmembers WHERE Id = :camp.Id AND LeadId != null ) from Lead WHERE Id= :lead.id ];
return CampaignMembers;
}
}
Here the problem is your Lead is a List type variable so you can't access a list like lead.id
You have to mention the index.
in your case i think you have to use loop for that list. (If you have many leads )
Other wise set 0 index on it
i.e lead[0].id
Regards
Virendra
Can you please tell me how to use loop to get the current lead value?
Thanks
What do you mean by current Lead?
"In campaign Layout" there is one section "Campaign Member" in that we get the campaign member details...so basically i am trying to customize those details through code."
I mean if you have a campaign id then you can find the CampaignMembers realated it.
SELECT id,name FROM CampaignMember WHERE campaignid =:camp.id
You have to use Set instead of list.
1.so you can write set on the query
first change your list of lead to set. ANd then
2. Or you have to use For loop. like
first create a Set (type of Id) After that SOQL query:
try any one of them.
Note:The code is not tested so correct syntaxt eror if occure.
Regards
Virendra
try this Query
Below is my code..
public with sharing class CampaignMemController {
public Campaign camp {get; set; }
public CampaignMemController(ApexPages.StandardController controller) {
camp = (Campaign)controller.getRecord();
}
List<Lead> sLead = new List<Lead>([SELECT id FROM Lead]);
List<Lead> leadlist = new list<Lead>();
public List<Lead> CampaignMembers;
public List<Lead> getCampaignMembers() {
CampaignMembers=[Select Id,Name,(Select id, Campaign.Name,Contact.Phone,Lead.FirstName,Lead.LastName,LeadID,ContactID,Lead.Phone,Lead.Email, Lastmodifieddate,Status,CampaignId,Campign_ID__c,Lead.MobilePhone From CampaignMembers where CampaignId =:camp.Id and Status != '' and LeadId IN : slead ),
(Select Subject, Id,lastModifiedDate From ActivityHistories where lastModifiedDate !=null and Subject !=null order by LastModifiedDate desc limit 1)
from Lead WHERE Id IN : slead and Name !=NULL order by LastModifiedDate desc];
return CampaignMembers;
}
}
you can't use list like where id IN :
so raplace this code: with this
I tried that also...Now i am getting an error on highlighted line
Error: Invalid initial value type LIST<Lead> for SET<Id>
public with sharing class CampaignMemController {
public Campaign camp {get; set; }
public CampaignMemController(ApexPages.StandardController controller) {
camp = (Campaign)controller.getRecord();
}
Set<Id> sLead = new set<Id>([SELECT id FROM Lead]);
List<Lead> leadlist = new list<Lead>();
public List<Lead> CampaignMembers;
public List<Lead> getCampaignMembers() {
CampaignMembers=[Select Id,Name,(Select id, Campaign.Name,Contact.Phone,Lead.FirstName,Lead.LastName,LeadID,ContactID,Lead.Phone,Lead.Email, Lastmodifieddate,Status,CampaignId,Campign_ID__c,Lead.MobilePhone From CampaignMembers where CampaignId =:camp.Id and Status != '' and LeadId IN : slead ),
(Select Subject, Id,lastModifiedDate From ActivityHistories where lastModifiedDate !=null and Subject !=null order by LastModifiedDate desc limit 1)
from Lead WHERE Id IN : slead and Name !=NULL order by LastModifiedDate desc];
return CampaignMembers;
}
}