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
admin adpadmin adp 

How to automatically create a record in child object based on field in parent object

Parent Object

Record 1:

Primary Country (picklist):  Country 1

Secondary Countries (multi-picklist): 

Country 2

Country 3

Country 4

 

Given the above record on the parent object, I want the following records to be automatically created on the child object:

 

Child Object:

Record 1:

Project Country:  Country 1

Primary Country: Yes

Record 2:

Project Country: Country 2

Primary Country: No

Record 3:

Project Country: Country 3

Primary Country: No

Record 4:

Project Country: Country 4

Primary Country: No

Chris ZhuangChris Zhuang

It's quite easy to achieve by using Apex Trigger, please use the template below to start with.

 

trigger PrimaryCountry_After_InsertUpdate on Primary_Country__c (after insert, after update)
{

    //get you Primary Country selections

 

    //insert the child object based on the Primary country
}