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
PAWAN THOSARPAWAN THOSAR 

Write an apex program, to Remove all the Hiring Manager Records from the object, who names are starting with the specified characters at runtime.

Best Answer chosen by PAWAN THOSAR
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Pawan,

Can you try the below code 
 
public class DeleteHiringManager {
    
    public void Deletehmanager( String S){
        String namelike= S+'%';
        List< Hiring_Manager__c > hm= [select Id,Name from Hiring_Manager__c where Name LIKE :namelike];
        delete hm;
        
    }

}

you can execute the above method from anonomous window by using below code.
Replace S with what ever aplhabet you need .
DeleteHiringManager IL= new DeleteHiringManager();
IL.Deletehmanager('s');

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Pawan,

Can you try the below code 
 
public class DeleteHiringManager {
    
    public void Deletehmanager( String S){
        String namelike= S+'%';
        List< Hiring_Manager__c > hm= [select Id,Name from Hiring_Manager__c where Name LIKE :namelike];
        delete hm;
        
    }

}

you can execute the above method from anonomous window by using below code.
Replace S with what ever aplhabet you need .
DeleteHiringManager IL= new DeleteHiringManager();
IL.Deletehmanager('s');

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
This was selected as the best answer
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Pawan,

Did you tried the above code?

Thanks,