You need to sign in to do that
Don't have an account?
Sainath Venkat
trigger to update parent from child record status
I need help in writing a trigger here. I have two objects
1) Opportunity
2) Opportunity_Programs__c
I have lookup relationship between them, opportunity is parent and Opportunity_Programs__c is child, so one opportunity can have multiple Opportunity_Programs__c.
I have Status__c field in Opportunity_Programs__c object, so if Opportunity_Programs__c records that related to particular opportunity has Status__c value as "Open" then I need to update Opportunity stage to Open, if Stage__c is "Close" then I need to update Opportuntiy stage to "Closed Lost"
Can anyone help me out in this issue here
1) Opportunity
2) Opportunity_Programs__c
I have lookup relationship between them, opportunity is parent and Opportunity_Programs__c is child, so one opportunity can have multiple Opportunity_Programs__c.
I have Status__c field in Opportunity_Programs__c object, so if Opportunity_Programs__c records that related to particular opportunity has Status__c value as "Open" then I need to update Opportunity stage to Open, if Stage__c is "Close" then I need to update Opportuntiy stage to "Closed Lost"
Can anyone help me out in this issue here
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Use the blow code it will helpfull for you.
-----trigger---------- ------apex code----------
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
thanks for the help but the trigger that you provide is not looping all the child records, it just looking into the inserted record but not existing child record, if all the child records are open then my trigger should set stage to Closed Won, if any of the child contains status as close then stage should be closed Lost