My goal is to enable my team to update a particular field on the Opportunity Object (Stage__c) to 'Closed Won', and have that auto-generate a new custom child object (Onboarding) that is linked to the same account that the Opportunity is linked to.
At this point, I have produced the following trigger but am continuously prompt with
"Error: Compile Error: Invalid field Stage__c for SObject Opportunity at line 6 column 17"
Below is my entire trigger. Any thoughts/advice are greatly appreciated!
trigger CreateOB on Account (after insert, after update) {
Onboarding__c[] inserts = new Onboarding__c[] {};
for (Opportunity a : Trigger.new) {
if (a.Stage__c == 'Closed Won') {
Account old = Trigger.oldMap.get(a.Id);
if (a.Stage__c != old.Stage__c) {
inserts.add(new Onboarding__c(Account_Name__c = a.Id));
}
}
}
insert inserts;
}