How to Delete the Bad Leads in Salesforce.Bad Leads Means in Lead object have Company Field.
Somany Websites Using Web2Lead. Fill the Information in WebSite Click On Save button information is Stored into Lead Object.That time Defaultly Company Field is Stored the 'Google' Value.
So this is the Bad Leads here i Delete the Bad Leads after inserted based on Condition whenever Company Field is Stored 'Google' that Record will be Deleted Automatically Using Apex Class and Trigger in Salesforce.
Apex Class:
public class DeleteLeads
{
public static void addHelloWorld(Lead[] accs)
{
List<Lead> lead= [Select l.Company, l.Id from Lead l WHERE l.Company ='Google'];
//Id Lead1Id= Lead[0].Id;
Lead lea = new Lead();
lea.Company = 'Google';
if(lea.Company =='Google')
delete lead;
else
{
insert lead;
}
}
}
in above class i selected company name and id From Lead and Condition is
if(lea.Company == 'Google')
after i Created Trigger for this Class
Trigger :
=========
trigger deletelead on Lead (after insert) {
if(trigger.isinsert){
List<Lead> lead = new List<Lead>();
DeleteLead.addHelloWorld(lead);
}
}
Here DeleteLead.addHelloWorld(lead) means Class Name.Method Name(var)
So............Using Apex Class and Trigger I Prevent the Bad Leads in Salesforce.
Somany Websites Using Web2Lead. Fill the Information in WebSite Click On Save button information is Stored into Lead Object.That time Defaultly Company Field is Stored the 'Google' Value.
So this is the Bad Leads here i Delete the Bad Leads after inserted based on Condition whenever Company Field is Stored 'Google' that Record will be Deleted Automatically Using Apex Class and Trigger in Salesforce.
Apex Class:
public class DeleteLeads
{
public static void addHelloWorld(Lead[] accs)
{
List<Lead> lead= [Select l.Company, l.Id from Lead l WHERE l.Company ='Google'];
//Id Lead1Id= Lead[0].Id;
Lead lea = new Lead();
lea.Company = 'Google';
if(lea.Company =='Google')
delete lead;
else
{
insert lead;
}
}
}
in above class i selected company name and id From Lead and Condition is
if(lea.Company == 'Google')
after i Created Trigger for this Class
Trigger :
=========
trigger deletelead on Lead (after insert) {
if(trigger.isinsert){
List<Lead> lead = new List<Lead>();
DeleteLead.addHelloWorld(lead);
}
}
Here DeleteLead.addHelloWorld(lead) means Class Name.Method Name(var)
So............Using Apex Class and Trigger I Prevent the Bad Leads in Salesforce.
No comments:
Post a Comment