Trigger to update parent records field when child record is updated

Vijay Kumar
2 min readAug 5, 2020

--

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

Other post that would you like to learn

Step 1:- Apex Class Trigger : checkboxStatus.apxt

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

Originally published at https://www.w3web.net on August 5, 2020.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response