Trigger Fieldupfdate on Employee1__c (after insert, after update) {
public static Boolean bool = true;
if(bool){
bool = false;
List<Employee1__c> listemp = new List<Employee1__c> ();
Set<Id> setid = new Set<id>();
for(Employee1__c empp:trigger.new){
setid.add(empp.id);
}
List<Employee1__c> listem = [Select id,lastname__c from Employee1__c where id In : Setid];
for(Employee1__c emp:listem){
if(emp.LastName__c==null){
emp.Lastname__c = 'Sampath';
listemp.add(emp);
}
} update listemp;
}
}
public static Boolean bool = true;
if(bool){
bool = false;
List<Employee1__c> listemp = new List<Employee1__c> ();
Set<Id> setid = new Set<id>();
for(Employee1__c empp:trigger.new){
setid.add(empp.id);
}
List<Employee1__c> listem = [Select id,lastname__c from Employee1__c where id In : Setid];
for(Employee1__c emp:listem){
if(emp.LastName__c==null){
emp.Lastname__c = 'Sampath';
listemp.add(emp);
}
} update listemp;
}
}
write scenarios and conditions with the triggers, it will be helpful to understand the trigger
ReplyDelete