You need to sign in to do that
Don't have an account?
Harnoor Singh 9
Query for related Lookups
I have a Lead with LastName as 'Lead'. It is added to a Campaign with name 'test'. The following Query isn't working.
SELECT Id, Campaign__c.Name from Lead where LastName='Lead'
SELECT Id, Campaign__c.Name from Lead where LastName='Lead'
Campaign and lead are not directly related. They are related through campaign member object. You might have to tweak your SOQL like this -
SELECT LeadIdFROM CampaignMember WHERE CampaignId='XXX'
where XXX is the Id of your Campaign named Test
Cheers,
Aparna Hegde
Thank you for your help, it has been very useful. But what if i want to get Campaign Id using Lead Id?
select campaignId,campaign.name from campaignmember where LeadId='XXX'
Since campaign object is campaign member's parent, you can get any field from campaign using campaign.fieldname in the above SOQL.
Cheers,
Aparna
If you have a few of the leads, you can do it through UI. Go to Campaigns tab and add members. You can select the leads you want to add. If you have a lot then do it using data loader. You can make a csv file with Lead Id, and Campaign Id and all other details you have and execute through the same. You can also reach out to salesforce support to help you further on this.
Cheers,
Aparna Hegde