Timeline for Apex Trigger For New Child From Field Update
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 4, 2014 at 23:08 | vote | accept | Dave | ||
Dec 4, 2014 at 20:58 | comment | added | Dave | trigger CreateOB on Account (after insert, after update) { Onboarding__c[] inserts = new Onboarding__c[] {}; for (Opportunity a : Trigger.new) { if (a.StageName == 'Closed Won') { Opportunity old = Trigger.oldMap.get(a.Id); if (a.StageName != old.StageName) { inserts.add(new Onboarding__c(Account_Name__c = a.Id)); } } } insert inserts; } | |
Dec 4, 2014 at 20:57 | comment | added | Dave | Hi Eric, Thanks for all of your help on this! I updated my trigger based on your comments above and below but now I am seeing a new error. You were correct that I was using the wrong field value, mental hiccup I suppose. Now the problem seems to be that I am attempting to create an Onboarding page (custom child obj) from a field change on the Opportunity page (child obj) and have the new Onboarding page linked to the same Account that the Opportunity was linked to. In my next comment will be the code I currently have and the error I am receiving. | |
Dec 4, 2014 at 1:42 | history | answered | Eric | CC BY-SA 3.0 |