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
Dilyan DimitrovDilyan Dimitrov 

How to stop converting Lead to Account in trigger without addError() method

Hi,

I would like to know How to stop converting Lead to Account in before insert trigger without addError() method?

To be more precise what I need to acheve:
1. Stop the process of converting Lead to Account.
2. Display message in the convert Lead to Account page that the respective Lead is not converted.
3. Set and Update the Lead.Status__c field to 'Existing Deal'.

I've tried to achieve the above in before insert trigger and I used addError() method in order to stop the process of converting Lead to Account as well as to dispaly message that the Lead is not converted but the problem is that the addError() method is making a rollback of my changes and I can neither save nor update my changes and records into the Lead database table.
I used @future method as well as a savepoint because I thought it will help me to set and update my changes but that did not help at all. Therefore I decided to start investigating and searching for a feasible way to achive what I want via VF by using controller.

Could you please advise how achive what I want either by using trigger or controller?

Regards,

Dilyan
Andy BoettcherAndy Boettcher
You cannot interrupt the standard lead convert functionality with anything outside of a trigger.addError.  What I would recommend is that you create your own "Convert" process via Visualforce where you can perform all of your business logic PRIOR to calling the standard lead convert functionality.

Remove the stock "Convert" button from the Lead Page Layout and replace it with your own button/VF page.
Dilyan DimitrovDilyan Dimitrov

Hi,

Thank you for your answer.

What I would like to know and what I need is to extend the leadConvert class and override the convert button funcionality.

Could you please advise as well as include an example/code on how to extend the LeadConvert class and override the convert button functionality.

Regards,

Dilyan

Andy BoettcherAndy Boettcher
Dilyan,

You cannot extend the native leadConvert class.  You can create your own Visualforce/Apex solution that applies your business logic BEFORE you manually call the leadConvert class.