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

Trigger to update a related record?
Hello
We have a custom object Individual Email Sends and I'm trying to write a trigger that updates a text field (Emails__c) on the related Account (lookup field).
So every time a new Individual Email is sent, it would then add the name of this email to the Email__c field, without deleting the previous data in it.
I know I'll need to create a List of all the Individual Email Sends, with after insert and after update.
Then a List of related Accounts that need to be updated, but how do I find the related Accounts for it?
Thanks!
We have a custom object Individual Email Sends and I'm trying to write a trigger that updates a text field (Emails__c) on the related Account (lookup field).
So every time a new Individual Email is sent, it would then add the name of this email to the Email__c field, without deleting the previous data in it.
I know I'll need to create a List of all the Individual Email Sends, with after insert and after update.
Then a List of related Accounts that need to be updated, but how do I find the related Accounts for it?
Thanks!
I have made some changes in Line no 18 to get the Name from Child and assign it to Account's text field.
So, Text field in Account will be updated with Name from Child record.
Thanks,
Vinoth
All Answers
Please find the below Code Sample for updating the field in related(look up) Account object.
Thanks,
Vinoth
Hello Vinoth, thank your for the help! =)
As I understand this trigger will insert a certain value (set in Mail Subject) to the TextField.
However I'll need it to take the Mail Subject from the name field from the Child__c object.
(As this trigger will fire every time a new EmailSend is happening, the idea is to collect the Email names on the Account level.)
I have made some changes in Line no 18 to get the Name from Child and assign it to Account's text field.
So, Text field in Account will be updated with Name from Child record.
Thanks,
Vinoth
You are awesome, Vinoth!
Thank you, this code works perfectly. Learned to understand Maps in the process as well.