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
amoldavskyamoldavsky 

Lead Source list

Hi,

 

Does anybody know how I can get all Lead Sources, created in the specific org, from within APEX code?

 

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
JPClark3JPClark3

The Lead Source is a Picklist on the lead object.

In the Apex help , lookup the "Describe Field Result Methods" and PicklistEntry.

All Answers

JPClark3JPClark3

The Lead Source is a Picklist on the lead object.

In the Apex help , lookup the "Describe Field Result Methods" and PicklistEntry.

This was selected as the best answer
amoldavskyamoldavsky

Many thanks for the accurate pointer to the right solution, I would have spent countless hours looking for it myself.

 

// construct a list of currently configured and default Lead Sources
Schema.DescribeFieldResult leadDescribe = Lead.LeadSource.getDescribe();
List<Schema.PicklistEntry> leadDescribePickList = leadDescribe.getPicklistValues();

// clean up the list first and convert into a Map object
leadSourceList = new Map<String,String>();
for(Schema.PicklistEntry entry : leadDescribePickList) {
	if(entry.isActive()) {
		leadSourceList.put(entry.Label, entry.Value);
	}
}

 

Thanks

-Assaf