You need to sign in to do that
Don't have an account?
apexuser
How to create Lead using RecordType
Hi Folks,
I have a requirement like "creating Lead using RecordType",How to do this? Please let me know with some sample examples/codes and any suggestions.Any help appreciated.
Thanks.
You can invoke SOQL query for record type to fetch lead records.
Recordtype rd = [Select r.SobjectType, r.Name, r.Id From RecordType r where SobjectType = 'Lead'];
Hope this helps.
but how do you create lead here using the RecordType!!!!!!!!!!!!
Hi apexuser,
Assuming you have a few number of record types configured for lead, use the query posted by "Pradeep_Navatar" to get record types for lead in the code. Then you choose which one is the right one to create the Lead record
e.g.
if you want to create a lead record with record type "Global Channels Lead"
Id globalChannelRTId;
List<RecordType> lsRt = [Select r.SobjectType, r.Name, r.Id From RecordType r where SobjectType = 'Lead'];
for(RecordType rt: lsRt){
if(rt.Name == 'Global Channels Lead"){
globalChannelRTId = rt.Id;
}
}
Lead l = new Lead(RecordTypeId = globalChannelRTId, lastname= 'My Global Lead');
// set all the required fields
insert l;
cheers..