function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yakup kaygusuzyakup kaygusuz 

Visual force dynamic SOQL queries on custom fields


I am having an issue with this SOQL query doesn't recognise the relation ship between a campaign and a contact

heres the code

public String crmid { get; set; }

public List<SelectOption> getValues(){
cmoptions.clear();
cmoptions.add(new selectOption('--None--','--None--'));

for(Campaign camp:[select id,name, (select id,status,contactId,Status_Changed__c,Call_Result__c, Contact.Account.PersonMobilePhone, Contact.Account.PersonEmail, Contact.Account.Name, Contact.Account.G1_Client_Relationship_Manager__c,Contact.Account.Mobile_Clean__c, Contact.Account.PersonHomePhone,Contact.Account.PersonMailingStreet, Contact.Account.PersonMailingCity,Contact.Account.PersonMailingState, Campaign.name from CampaignMembers) from Campaign WHERE Campaign_Call_List__c = true AND Contact.Account.G1_Client_Relationship_Manager__c = :crmid ORDER BY Name ASC]){

cmoptions.add(new selectOption(camp.id,camp.name));
maplstcm.put(camp.id,camp.campaignmembers);
}
return cmoptions;
}
Best Answer chosen by yakup kaygusuz
pbattissonpbattisson
You will need to do a second query like:

SELECT ContactId, Contact.FirstName, Contact.LastName, Contact.Phone FROM CampaignMember WHERE CampaignId='XXX'

using your campaignId. Then update your lists and maps as needed.