Find your content:

Search form

You are here

How Updating a Record's Parent Affects a Before Trigger That Pulls Data From Parent's Fields


I have a Before Insert, Before Update trigger on a custom object, Financial Account, that is a child in a master-detail relationship with Account. When the Financial Account is updated/inserted, the trigger pulls the lookup field 'Portfolio Manager' from the account, and updates the 'Portfolio Manager' lookup field on the Financial Account.

If the field changed on Financial Account (which allows re-parenting) is the Account that it is linked to, will the 'Portfolio Manager' field on Financial Account be pulled from the old Account that it is linked to, or the new Account that it is being linked to?


EDIT: Added relevant code.


trigger transferRelationshipTeamFromAcctOnFinAcctUpdate on Financial_Account__c (before insert, before update) {


public class FinancialAccountManager {
public static void handleUpdateTransferRelationshipTeamFromAcct(List<Financial_Account__c> FinAcctsTrNew){
    Set<Id> clients = new Set<Id>{};
    for(Financial_Account__c finAcct : finAcctsTrNew){
        //Compile a set of all clients from all FinAccts in

    //Get the client's fields
    Map<Id, Account> clientsMap = new Map<Id, Account>([
        SELECT Id, Wealth_Advisor__c, Portfolio_Manager_Lookup__c,Trust_Officer__c, Other_Team_Member_1__c, Other_Team_Member_2__c
    FROM Account
    WHERE Id IN :clients]);

    //Loop through each Financil Account
    for(Financial_Account__c finAcct : FinAcctsTrNew){
        //Update the Relationship Teams on the Financial Account from the Parent Account
        finAcct.Wealth_Advisor_Lookup__c = clientsMap.get(finAcct.client__c).Wealth_Advisor__c;

        finAcct.Portfolio_Manager_Lookup__c = clientsMap.get(finAcct.client__c).Portfolio_Manager_Lookup__c;

        finAcct.Trust_Officer_Lookup__c = clientsMap.get(finAcct.client__c).Trust_Officer__c;

        finAcct.Other_Team_Member_1_Lookup__c = clientsMap.get(finAcct.client__c).Other_Team_Member_1__c;

        finAcct.Other_Team_Member_2_Lookup__c = clientsMap.get(finAcct.client__c).Other_Team_Member_2__c;

Attribution to: jackerman09

Possible Suggestion/Solution #1

If you're using the account lookup from the Trigger.New, You should be getting the financial account from the new parent on a before update.

Attribution to: Samuel De Rycke
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content