You need to sign in to do that
Don't have an account?
Reppin505
Trigger to Update Related Account Record from Opportunity Object Not Working
Desparately need some help. I cannot get this trigger to update the related acount record fromt the opportunity object.
trigger updateAccountsOnChange on Opportunity (before update) { Map<Id, Opportunity> oppWithNewEndDates = new Map<Id, Opportunity>(); for (Integer i = 0; i < Trigger.new.size(); i++) { if ( (Trigger.old[i].Name != Trigger.new[i].Name)) { oppWithNewEndDates.put(Trigger.old[i].id,Trigger.new[i]); } } List<Account> updatedAccounts = new List<Account>(); for (Account c : [SELECT ID, Name FROM Account WHERE ID in :oppWithNewEndDates.keySet()]) { Opportunity parentOpportunity = oppWithNewEndDates.get(c.Id); c.Description = parentOpportunity.Id; //c.Salutation_Name__c = parentOpportunity.Name; //c.Name = parentOpportunity.Name; updatedAccounts.add(c); } update updatedAccounts; }
Did you run this with Debug Log on (or from a testMethod) so you can see how it's executing and spot any errors?
And what is it you're actually trying to do? This seems nonsensical to me.