Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RelatedContacts
- {
- public Static List<Contact> Relatedcontacts = new List<Contact>();
- public static integer count=0;
- public Static List<Lead> OtherLeads = new List<Lead>();
- public static void LeadConvertion(Map<Id,Id> RelatedLeads)
- {
- List<Database.LeadConvert> converts = new List<Database.LeadConvert>();
- String convertedStatus = [SELECT MasterLabel FROM LeadStatus WHERE IsConverted = TRUE LIMIT 1].MasterLabel;
- for(Lead Ls:[Select id,Parent_Lead__c from lead where Parent_Lead__c=:RelatedLeads.keyset()])
- {
- If(Ls.Parent_Lead__c <> null && count <20)
- {
- Database.LeadConvert lc = new Database.LeadConvert();
- lc.setLeadId(Ls.Id);
- lc.setConvertedStatus(convertedStatus);
- lc.setAccountId(RelatedLeads.get(Ls.Parent_Lead__c));
- lc.setDoNotCreateOpportunity(true);
- converts.add(lc);
- count =count+1;
- }
- if(Ls.Parent_Lead__c <> null && count >=20)
- {
- //Lead lss=new lead();
- Lead ll=new Lead(Id = Ls.Id);
- //ll.id=Ls.id;
- Count=Count+1;
- //ll.Status='Not Visible';
- ll.Parent_Lead__c='';
- OtherLeads.add(ll);
- //OtherLeads.add(lss);
- }
- }
- If(!OtherLeads.isEmpty())
- {
- Update OtherLeads;
- }
- Database.convertLead(converts, false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement