You need to sign in to do that
Don't have an account?

Relationship query on campaign
Hi All,
when i write
for(campaign camp : [SELECT Name, (SELECT id FROM tasks) FROM Campaign where name='1-ID-H-NAS-37']){
task [ ] l= camp.tasks;
}
no error is given but when i write
for(campaign camp : [SELECT Name, (SELECT id FROM leads) FROM Campaign where name='1-ID-H-NAS-37']){
lead[ ] l= camp.leads;
}
an error is thrown saying, "Invalid field leads for SObject Campaign"..
I checked in WSDL, both Leads and Tasks are present under Campaign object .
Could anybody please comment on it. why it is happening?
Thanks,
Mahi
Hi Mahi,
The relationship between the Campaign and Lead is not like the relationship between campaign and task.
The Task is a child of campaign but not the lead.
I think you are probably tiring to get all the leads which are associated to a particular campaign member.
For this just find out the Campaign id.
And fire the below query
Select LeadId FROM CAMPAIGNMEMBER WHERE campaignid= ''
Thanks and Regards,
Dinesh Nasipuri