You need to sign in to do that
Don't have an account?
Karen Davis 1
Can I write a trigger to update a field on account from a child object?
I’m trying to write a before delete trigger on a custom object called “Dental_Assessment” so that if the ID of the record being deleted is the same as a field on the account it will set that field on the account to null. "Dental_Assessment" is a child object of custom object "Treatment" which is a child object of Account. I thought I had it, but I can’t figure out how to get it to update the account record. can anyone help me with the syntax for doing this?
This is my trigger, except line 5 doesn’t work:
trigger DeleteID on Dental_Assessment__c (before delete) {
if(System.Trigger.IsDelete) {
for (Dental_Assessment__c Assmt: trigger.old) {
if(Assmt.ID = Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c) {
Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c = null;
}
}
}
}
This is my trigger, except line 5 doesn’t work:
trigger DeleteID on Dental_Assessment__c (before delete) {
if(System.Trigger.IsDelete) {
for (Dental_Assessment__c Assmt: trigger.old) {
if(Assmt.ID = Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c) {
Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c = null;
}
}
}
}
All Answers
Please find below code for updating Account based on Dental Assessment:
Hope this will help you, also let me know if you find any issues on this.
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com