Trigger that creates child record on creation of parent record only if checkbox is true
I was wondering if someone could help a newb to SFDC come up with the code for an apex trigger.
Here's the scenario:
I have a custom object called payments (Payments__c) - a child object of opportunities - and I would like a payment record to be created after a new opportunity record is created, but only if a checkbox is checked (Create_New_Payment__c).
There are a few fields on the new payment record that need to be pre-populated:
- The opportunity field (obviously)
- Payment amount (Amount__c) should equal the amount of the opportunity (the payment amount field is not a formula field and can't be, but maybe this can be accomplished with workflow - if Create_New_Payment__c is true, payment amount equals opportunity amount??)
- Paid__c checkbox equals true
So is this possible to do?
Thanks for any help.