You need to sign in to do that
Don't have an account?

dml exception which working for before trigger event but its not working for after trigger event plz explain here .i have two custom fields position1__c and candidate1__c with lookup.when ever i try to update email getting exception
trigger actrig on position1__c (after insert) {
list<candidate1__c> candlist=new list<candidate1__c>();
map<id,position1__c> mymap=new map<id,position1__c>();
list<candidate1__c> canlist=[select id,email__c,position1__c from candidate1__c where position1__c=:mymap.keyset()];
for(candidate1__c ca:canlist){
ca.email__c=mymap.get(ca.position1__c).email__c;
candlist.add(ca);
}
update candlist;
}
list<candidate1__c> candlist=new list<candidate1__c>();
map<id,position1__c> mymap=new map<id,position1__c>();
list<candidate1__c> canlist=[select id,email__c,position1__c from candidate1__c where position1__c=:mymap.keyset()];
for(candidate1__c ca:canlist){
ca.email__c=mymap.get(ca.position1__c).email__c;
candlist.add(ca);
}
update candlist;
}
I thought i gave you proper working solution previously. But no problem to tell you again that your "mymap" is blank and without putting any check of null you are trying to get values thats why you are getting error. Thanks
Hemant
Review all error messages below to correct your data.
Apex trigger trigb23 caused an unexpected exception, contact your administrator: trigb23: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.trigb23: line 15, column 1