You need to sign in to do that
Don't have an account?
Ivan Winzer
Push contact field data on account record
So the company has an ID that is being pushed from a third party to a contact record in SF. But we also need this info on the account the contact is associated with (mind you we have one contact to one account *it was already setup that way before i got the job*). So im trying to buidl a trigger that when a data is updated on the contact it will push that info onto the assoicated account. Below is what i have peiced together so far but i keep getting this 'missing EOF at (parentobjlist) error when i try to save it. Can anyone help...
trigger pushRevelID on Contact (after insert, after update) {
List<Account> parentObjList = new List<Account>();
List<Id> listIds = new List<Id>();
List<Contact> newRevel = new Contact[]{};
for (Contact childObj : Trigger.new {
listIds.add(childObj.Account);
newRevel.put(childObj.Account, Contact);
}
parentObjList = [SELECT id, Name FROM Account WHERE ID IN :listIds]; (ERROR HAPPENING ON THIS LINE)
for (Account acct : parentObjList){
acct.Revel_ID__c = newRevel.get(acct.Id).Revel_ID__c;
}
update parentObjectList;
}
trigger pushRevelID on Contact (after insert, after update) {
List<Account> parentObjList = new List<Account>();
List<Id> listIds = new List<Id>();
Map <Id,Contact> newRevel = new Map<Id,Contact>();
for (Contact childObj : Trigger.new) {
listIds.add(childObj.AccountId);
newRevel.put(childObj.AccountId, childObj);
}
parentObjList = [SELECT id, Name FROM Account WHERE ID IN :listIds];
for (Account acct : parentObjList){
acct.Revel_ID__c = newRevel.get(acct.Id).Revel_ID__c;
}
update parentObjList;
}
All Answers
this should be a map
So it should be something like
So i changed that but the error on line 12 stll exist.
trigger pushRevelID on Contact (after insert, after update) {
List<Account> parentObjList = new List<Account>();
List<Id> listIds = new List<Id>();
Map <Id,Contact> newRevel = new Map<Id,Contact>();
for (Contact childObj : Trigger.new) {
listIds.add(childObj.AccountId);
newRevel.put(childObj.AccountId, childObj);
}
parentObjList = [SELECT id, Name FROM Account WHERE ID IN :listIds];
for (Account acct : parentObjList){
acct.Revel_ID__c = newRevel.get(acct.Id).Revel_ID__c;
}
update parentObjList;
}