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

Trigger to update field on parent based on related object field but based on created date
I have to write a trigger where i have a custom object in the related list of the parent opportunity object. The parent Opportunity has a comments field.
The user is allowed to create a new text under the custom object and every time a new record is created or updated the value in the parent must be replaced with the new value,
I can write a basic triiger on after insert and after udpated. Where i am not clear is the logic that a record is updated will not be the latest record created, how can the logic be added such the any record that is updated will get replaced with edited one.Kindly help me
The user is allowed to create a new text under the custom object and every time a new record is created or updated the value in the parent must be replaced with the new value,
I can write a basic triiger on after insert and after udpated. Where i am not clear is the logic that a record is updated will not be the latest record created, how can the logic be added such the any record that is updated will get replaced with edited one.Kindly help me
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
I saw your response, can you please confirm regarding the reference here.
You assigned the value in line no 17, so value will be updated in map varibale.
I am bit confused about when system will maintain reference and not?