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

SOQL Join between Campaign and Lead provides null result for a specific campaign
Hello,
We have a lead associated with a campaign and we can check it is ok via the user interface.
But when trying to programmatically retrieve this relationship via SOQL e.g.
SELECT Campaign__c, Campaign__r.Name, Campaign__r.Id, Owner.Name, Name FROM Lead where name ='TheUserName'
Campaign__r.Name is null
However, the following SOQL
SELECT Campaign__c,Campaign__r.Name, Campaign__r.Id, Owner.Name, Name, SystemModstamp FROM Lead where Campaign__r.Name <> ''
returns results and shows it works fine for the other campaigns.
Do you have any idea why it doesn't work for this specific campaign?
Thanks in advance
We have a lead associated with a campaign and we can check it is ok via the user interface.
But when trying to programmatically retrieve this relationship via SOQL e.g.
SELECT Campaign__c, Campaign__r.Name, Campaign__r.Id, Owner.Name, Name FROM Lead where name ='TheUserName'
Campaign__r.Name is null
However, the following SOQL
SELECT Campaign__c,Campaign__r.Name, Campaign__r.Id, Owner.Name, Name, SystemModstamp FROM Lead where Campaign__r.Name <> ''
returns results and shows it works fine for the other campaigns.
Do you have any idea why it doesn't work for this specific campaign?
Thanks in advance
List<CampaignMember> campaignMembers=[SELECT CampaignID, LeadID, Status FROM CampaignMember WHERE CampaignID =: CampaignID__c];
Set<ID> LeadIDs= new Set<ID>();
For (CampaignMember CM: campaignMembers )
{
if(LeadIDs.contains(CM.LeadID)==FALSE)
{
LeadIDs.add(CM.LeadID);
}
}