0

Is there a way to call the existing standard action of Lead Convert inside a custom lighting component? I need to show a modal with some validations and if it seems correct by the user, click inside the modal the Convert standard action/button. Thank you!

0

There is no interface to convert a Lead directly through Lightning Components.

However you can use your Apex controller for that. Here's the example how to convert Lead programmatically (full reference in Apex Developer Guide: Converting Leads):

Lead myLead = new Lead(LastName = 'Fry', Company='Fry And Sons');
insert myLead;

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
| improve this answer | |
  • Thank you!! I have a question based on your answer, the standard mapping functionality Map Lead Fields for custom fields it's 'fired' when I call convertLead() method? If on setup of lead objet I set x custom field on the lead object to map to x custom field on the oppty object this will work? – Pablo Mar 25 at 14:54
  • @Pablo Yes, the standard Lead Mapping logic should retain here. – Przemysław Tamoń Mar 25 at 14:57
  • Nice!! Thank you so much!! – Pablo Mar 25 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.