function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
QuanchiQuanchi 

Apex Trigger

Hello,

 

I need help with an Apex trigger.  I have one custom object connected to the Account object.  The custom object keeps track of active items.  I need an Apex trigger that populates a field on the main Account object based on what is in the child object.   See below.

 

Account Object

 Custom Fields Text Value 
 

Favorite Ice Cream:

Vanilla

 
 

Favorite Color:

Green

 
 

Favorite Fruit:

Apple

 
    
    

Child Object

Item Name

Active

Type

 

Vanilla

Yes

Ice Cream

 

Chocolate

No

Ice Cream

 

Apple

Yes

Fruit

 

Orange

No

Fruit

 

Green

Yes

Color

 

Purple

No

Color

 

Yellow

No

Color

 

Red

No

Color

 

So, in this example….since type = Color and Active = Yes, then the text value of “Green” is populated in the Favorite Color field on the Account object.  Hope this makes sense.

 

Thanks for any help.

AmitSahuAmitSahu

What is the base criteria?

 

Such as if there is any update on Account then the Account field should be updated or If there is a change in the Child object then the parent record will be updated ...

QuanchiQuanchi

The fields on the Account page are read only and will be updated only when there is an update, addition or deletion.