w3web.net -- update parent field from child object

Trigger to update parent records field when child record is updated

Hey guys, today in this post we are going to learn about How to update the parent record field based on child record trigger in Salesforce custom object

Real time scenarios:- Write a trigger on custom object where update parent records field whenever child record is inserted or updated.

Create two custom object, both are associated with lookup relationship with each other

1) Custom Object:- parentObjTrigger__c custom field:- Status__c (Checkbox boolean type)
2) Custom Object:- childObjTrigger__c custom field:- Status__c (Checkbox boolean type)

If status field of child object marked true then should be status field of parent object automatic marked as true.

Files we used in this post example:-

checkboxStatus.apxt Apex Class Trigger It is used for update parent object field based on child records

Custom Parent Object:- parentObjTrigger__c

Custom Field :- Status__c

 

Custom Parent Object with Custom Field It is parent custom object used for building a lookup relationship with childObjTrigger__c

Custom Child Object:- childObjTrigger__c

Custom Field:- Status__c

Custom Child Object with Custom Field It is child custom object that is lookup relationship and associated with parentObjTrigger__c

You can download file directly from github by click here

Final Output

w3web.net -- update parent records field from child object

Other post that would you like to learn

Step 1:- Apex Class Trigger : checkboxStatus.apxt

From Developer Console >> File >> New >> Apex Trigger

checkboxStatus.apxt [Apex Class Controller]

Other related post that would you like to learn

2 thoughts on “Trigger to update parent records field when child record is updated”

Leave a Comment

Contribute to Support If Some Value Added in Your Project or Website