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
Julie CurryJulie Curry 

before trigger for lead conversion to avoid validation rule error

I have a validation rule on leads that is interferring with lead conversion.  
I need to keep it and I don't want to uncheck the box that will stop enforcing all validation rules, etc at the time of lead conversion.  

To avoid the validation rule error it seems like I might be able to create a before trigger that will make the status of the lead 'qualified', then I could add to the validation rule 'and lead status is not qualified'.  I'm an admin, not a developer so I was wondering if I could get some help with this.  Does anyone have a similar before trigger and test class that they could share?

 
Raj VakatiRaj Vakati
Use this code

 In the Developer Console, click File | New | Apex Trigger Enter name and Select Lead Object 


 
trigger Leadqualifiedtrigger on Lead (before insert) {
 for(Lead l:System.Trigger.new) {
   l.Status='qualified'
 }
}