You need to sign in to do that
Don't have an account?
SarikaP
Trigger not fired when record updated using dataloader
I am trying to mass update records using dataloader. Once a record is updated, the trigger should be fired. I tried to update records but the trigger is not fired when used dataloader. When I manually update the record, the trigger is fired. Here's my code:
Trigger
if(trigger.isafter && (trigger.isinsert || trigger.isupdate))
{
UpdateExpirydate.UpdateCertDetails(Trigger.new);
}
Apex controller:
public static void UpdateCertDetails(List<Certification_Attendees__c> lstcertattendees)
{
List<String> cerType = new List<String>{'Certification','Exam Retake','Recertification'};
List<String> certLevel = new List<String>{'1','2','3'};
List<Contact> lstcontacts = new List<Contact>();
Set<Id> contactIds = new Set<ID>();
if(lstcertattendees != null && lstcertattendees.size() > 0)
{
for(Certification_Attendees__c att : lstcertattendees)
{
contactIds.add(att.Attendee__c);
}
System.debug('ContactIds' + contactIds.size());
if ( contactIds != null && contactIds.size() >0)
{
for(Certification_Attendees__c attendee : [Select c.Name, c.Level__c , c.Attendee__c,c.Certified_on__c,c.Expiry_Date__c,c.Type__c,c.Exam_Result__c from Certification_Attendees__c c where c.Attendee__c in: contactIds and
c.Exam_Result__c =: 'Passed' and c.Type__c in: cerType and c.Level__c in: certLevel order by c.Certified_on__c desc LIMIT 1])
{
if(attendee != null)
{
Contact con = new Contact();
con.Id = attendee.Attendee__c;
con.Certified_On__c = attendee.Certified_on__c;
con.Expiry_Date__c = attendee.Expiry_Date__c;
lstcontacts.add(con);
}
}
}
System.debug('lstcontacts.size()' + lstcontacts.size());
if(lstcontacts !=null && lstcontacts.size() > 0)
{
update lstcontacts;
system.debug('Certification details on Contact Records updated successfully');
}
}
}
Thanks in advance!
Trigger
if(trigger.isafter && (trigger.isinsert || trigger.isupdate))
{
UpdateExpirydate.UpdateCertDetails(Trigger.new);
}
Apex controller:
public static void UpdateCertDetails(List<Certification_Attendees__c> lstcertattendees)
{
List<String> cerType = new List<String>{'Certification','Exam Retake','Recertification'};
List<String> certLevel = new List<String>{'1','2','3'};
List<Contact> lstcontacts = new List<Contact>();
Set<Id> contactIds = new Set<ID>();
if(lstcertattendees != null && lstcertattendees.size() > 0)
{
for(Certification_Attendees__c att : lstcertattendees)
{
contactIds.add(att.Attendee__c);
}
System.debug('ContactIds' + contactIds.size());
if ( contactIds != null && contactIds.size() >0)
{
for(Certification_Attendees__c attendee : [Select c.Name, c.Level__c , c.Attendee__c,c.Certified_on__c,c.Expiry_Date__c,c.Type__c,c.Exam_Result__c from Certification_Attendees__c c where c.Attendee__c in: contactIds and
c.Exam_Result__c =: 'Passed' and c.Type__c in: cerType and c.Level__c in: certLevel order by c.Certified_on__c desc LIMIT 1])
{
if(attendee != null)
{
Contact con = new Contact();
con.Id = attendee.Attendee__c;
con.Certified_On__c = attendee.Certified_on__c;
con.Expiry_Date__c = attendee.Expiry_Date__c;
lstcontacts.add(con);
}
}
}
System.debug('lstcontacts.size()' + lstcontacts.size());
if(lstcontacts !=null && lstcontacts.size() > 0)
{
update lstcontacts;
system.debug('Certification details on Contact Records updated successfully');
}
}
}
Thanks in advance!
Please check this
Have a look:-
There are two types of triggers: