You need to sign in to do that
Don't have an account?
after undelete - isDeleted
In this org:
Affiliations__c is a non master relationship to Contact.
If a Contact is deleted, a trigger is fired and will delete the related affiliations!
What I want to do is : if a contact is undeleted, undelete the deleted related affiliations as well
My code :
trigger ContactAfterUndelete on Contact (after undelete) {
Affiliation__c[] affiliationsFired ;
Affiliation__c[] affiliationsToUpdate = new Affiliation__c[]{};
affiliationsFired = [Select id from Affiliation__c where isDeleted = true and (Affiliation_From_Contact__c in :Trigger.old or Affiliation_To_Contact__c in: Trigger.old) ALL ROWS] ;
for (Integer i=0 ; i< affiliationsFired.size() ; i++){
affiliationsFired[i].isDeleted = false ;
AffiliationsToUpdate.add(affiliationsFired[i]);
}
update AffiliationsToUpdate ;}
I've got an error because isDeleted is non Writeable!
Please, Can you give me some advices on how to solve this issue ?
Tkx,
Mig
All Answers