You need to sign in to do that
Don't have an account?
foodrunner
Query for a list of lead/Contact owners associated with active Campaigns
I am working with an unmanaged package from the appexchange and force.com labs called Campaign Call Down, and have been troubleshooting this requirement for customization for several hours.
I am needing to query across all active campaigns to formulate a list of campaign members by owner dropdown list. I have tried to create a nested soql statement but am coming up with an error
Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Lead> at line 416 column 44
Here is my Code:
public List<SelectOption> getowneritems(){ List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption( '1', 'SELECT' )); for( Campaign c:getactiveCampaigns()){ options.add( new SelectOption( lead.ownerid, c.leadowner.name)); } return options; public List<Campaign> getactiveCampaigns(){ if( activeCampaigns == null ){ activeCampaigns = [select id, (select lead.Ownerid, Contact.ownerid from CampaignMembers), Name, Ownerid, Owner.id, owner.name From Campaign where isActive = true and Include_in_Campaign_Call_Down__c = true order by name LIMIT 100]; } return activeCampaigns; }
How can I fix this?
Thank you
The options.add line doesn't look right - shouldn't it be:
I think this should be
I have made the changes and recieve the following error:
Here is the amended code:
How do I solve this?
Thank you
CampaignMember has lookup fields to Lead and Contact, so you can refer to the Lead or Contact owner by Campaign.CampaignMember.Lead.ownerId etc. You'll need to do SOQL relationship queries to pull those values before you construct the SelectObjects list.