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
ForceLoverForceLover 

LEad conversion through button

HI Everyone,

 

I override my standard convert button with a VF page ,which will convert lead to account ,contact,opportunity through controller.i have three roles in my org which are 'salesrep','executive','manager'.I need it should execute (LEad conversion) only when

 

1)  Sales Rep can convert their own leads, and Lead owned by a Queue they are a member of

2) If Sales Rep converts a lead owned by a Queue , then change ownership Contact, Account, Opportunity to Sales Rep user who is converting.

3) Sales Manager and Executive can convert their teams' leads. If a Sales Manager or Executive converts a sales user's Lead, ownership of lead, opportunity, account and contact should remain sales rep

 

i'm using this code

 

 

Database.LeadConvert  lc =newdatabase.LeadConvert();

lc.setLeadId(lead.Id);

 

LeadStatus convertstatus = [select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];

lc.setConvertedStatus(convertStatus.MasterLabel);

 

Database.LeadConvert[] lcArray =newDatabase.LeadConvert[] {lc};

Database.LeadConvertResult[] results = Database.convertLead(lcArray);

 

System.assert(results[0].IsSuccess());