You need to sign in to do that
Don't have an account?

Trigger Help:Update parent status based on child records changes
Hi ,
I need to write a trigger that updates the parent object field 'Status__c' based on its child statuses.
I have a custom parent object Order__c and child object Order_line__c
Both have a status field "status__c"
Now when the any of the child object status__c ='Open' ,the parent status__c is 'Open'
else the parent object status__c='Closed'.
I tried writing a trigger from the docs example,but it was confusing .....
Can somebody please help me with this?
Thanks!
You don't need Apex for this.
Add a Roll Up Summary to Order, to use Count on OrderItem where status = 'Open'.
Then add a formula field to Order to display the status of Open if the RUS Count > 0 or Closed if it's 0.
Simples ;-)
All Answers
You don't need Apex for this.
Add a Roll Up Summary to Order, to use Count on OrderItem where status = 'Open'.
Then add a formula field to Order to display the status of Open if the RUS Count > 0 or Closed if it's 0.
Simples ;-)
Hi Enth,
This was wonderful!!!!!!!!!!!!!!!!!
Thanks so much!!