Skip to main content

 Write an Apex Trigger, Name = DisqualifyTestLeads. 

Define logic to find Leads with ‘Test’ in the Name, Ignore Case. Validate that the Lead First/Last Name must not be Blank. 

IF ‘Test Lead’ found, system.debug(Lead First Name + ‘ ’ + Lead Last Name + ‘Will be disqualified!’); 

Add the disqualified Leads to a List, use for loop to iterate through the list and update Lead status field to ‘Disqualified’. 

1 answer
  1. Jul 6, 2022, 12:07 AM

    Shaik,

    you can use the following trigger.

    trigger DisqualifyTestLeads on Lead ( before insert ) {      String strTest = 'test';          for ( Lead objLead : trigger.new ) {              if ( strTest.equalsIgnoreCase( objLead.Firstname ) ||              strTest.equalsIgnoreCase( objLead.Lastname ) ) {                          System.debug(                  objLead.Firstname + ' ' + objLead.Lastname + ' Will be disqualified!'             );             objLead.Status = 'Disqualified';                  }          }  }

0/9000