You need to sign in to do that
Don't have an account?
Shahida Robertson
How to Copy Contact Email to Custom Account field?
Hello,
Disclaimer* I am an Admin with no knowledge of code, but I have to build a process and flow. In order to do this, I need this trigger to accomplish. I have created a custom field on the Account object called "Primary Contact Email." I need a trigger that will update this field with the Primary Contact's (lookup on the Account) email. Right now I have:
trigger UpdateAccountEmails on Contact (after update) {
Map<Id, Account> m = new Map<Id, Account>();
for(Contact c : Trigger.new){
if (Trigger.oldMap.get(c.Id).Email != c.Email) {
m.put(c.AccountId, new Account(Id = c.AccountId, Primary_Contact_Email__c = c.Email));
}
}
update m.values();
Can anyone help me? Thanks!
Disclaimer* I am an Admin with no knowledge of code, but I have to build a process and flow. In order to do this, I need this trigger to accomplish. I have created a custom field on the Account object called "Primary Contact Email." I need a trigger that will update this field with the Primary Contact's (lookup on the Account) email. Right now I have:
trigger UpdateAccountEmails on Contact (after update) {
Map<Id, Account> m = new Map<Id, Account>();
for(Contact c : Trigger.new){
if (Trigger.oldMap.get(c.Id).Email != c.Email) {
m.put(c.AccountId, new Account(Id = c.AccountId, Primary_Contact_Email__c = c.Email));
}
}
update m.values();
Can anyone help me? Thanks!
So in your process, the object would be a contact, your criteria for triggering the action would be:
- Email Is Changed Equals True.
- You might want a criteria to specify that this contact is the primary as opposed to any other contact on the account.
Your immediate action would be to update a record related to the contact. Choose the account. then set your field(s):