I need a trigger to update all child records of an Opportunity. Any help?
This is a simple code which update child field based on a parent's field value.
Could you check if you're on master-detail relationship? You might be able to use a workflow rule for this.
The child object actually has 2 lookup relationships with the master (Opportunity). Opportunities represent loans. There is an original loan and often a renewal of the loan. I need to link the renewal to the original loan or loans. Because there may be several origianl loans bundled to a renewal, I need a custom related object to tie them together. Therefore, I have a lookup to the renewal and master-detail to the original loans. IF I can trigger an update to the child recrods, then I can field update the priginal Opportunity records as "Renewed."
Could you post your current trigger code? Alternatively feel free to contact me via my profile if you need assistance.
My code so far...
//Opportunity is the parent object and Related_Deals__c is the child object
// They are linked by a lookup field Renewal_Deal__c
// For Record Type ID '012U00000009QIv' I need to copy the StageName from Opportunity to a text field Renewal_Stage__c.
Could you contact me via my profile to see if we can debug your current code?
One thing that I noticed is that the "update RDToUpdate;" shouldn't be in the loop. It should be outside the "for (Opportunity Opp : updOpps)" loop.
What problems are you having with it?
can help? Thanks!
Would you please provide the unit test code for this?
Thanks a lot.