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

Method to update Parent record after child deleted
Hello,
I have a class that updates a field on the Acocunt object when a Note is inserted or updated. I am having an issue on Delete.
If a Note is deleted I want to grab the remining Note with the most recent LastModifiedDate. I would use the body in this note to update the field on the Accoun the record. But I am not able to get that record. I just keep querying the record that is being deleted. So the Account field is never updated. And if there are no remaining noted I want the Account field to be null.
Thanks,
P
I have a class that updates a field on the Acocunt object when a Note is inserted or updated. I am having an issue on Delete.
If a Note is deleted I want to grab the remining Note with the most recent LastModifiedDate. I would use the body in this note to update the field on the Accoun the record. But I am not able to get that record. I just keep querying the record that is being deleted. So the Account field is never updated. And if there are no remaining noted I want the Account field to be null.
Thanks,
P
Glad that your trigger worked. Please try with below test class it should cover 100% . In case of further help on test class please try to create new thread. Hope this helps!
Thanks
All Answers
Add to your existing code with additional after delete criteria like below:
Trigger Code: Apex class with name UpdateAccountNote and class afterdelete. You can also add only Afterdelete() method to your existing class if you want to avoid many classes.
Hope this helps! Please mark as best answer if it does.
Thanks
Cheers,
P
All of the Notes are atatched to a single Account record so do I need pass the a list Thanks,
P
I think I got it, Would you be able to assist with some test class code coverage or do you want me to create a new post?
No coverage in these lines:
Thank you for all of your help:
P
Glad that your trigger worked. Please try with below test class it should cover 100% . In case of further help on test class please try to create new thread. Hope this helps!
Thanks