You need to sign in to do that
Don't have an account?
utahsalesforcedeveloper
SOQL Statement Error
I have Leads related to Accounts (Account__c field on Leads). I am trying to write a SOQL statement that pulls in all Leads and Contacts associated with specific Accounts. Here is a general SOQL which I thought should work, but keeps giving me an error message.
acc = [select id,name,industry,billingcountry,createdbyid,(select id,name,email,phone from contacts), (select id, FirstName, LastName from leads) from account limit 20];
I keep getting this error no matter how I try to pull the Lead relationship: COMPILE ERROR: Didn't understand relationship 'leads' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.
Any help would be greatly appreciated.
Thank you.
acc = [select id,name,industry,billingcountry,createdbyid,(select id,name,email,phone from contacts), (select id, FirstName, LastName from leads) from account limit 20];
I keep getting this error no matter how I try to pull the Lead relationship: COMPILE ERROR: Didn't understand relationship 'leads' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.
Any help would be greatly appreciated.
Thank you.
All Answers
There I no direct relationship exist between account and lead object.When a lead is converted into Account,Contact and opportunity there is some field in lead that contains the id of new Account, Contact and opportunity.
if you want to query the related lead then you have to extra soql query for that.
Refer the below code snippet as reference:
SELECT Id FROM Lead where ConvertedAccountId='0019000000njFTqAAM'