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 Trigger.new

    //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;

1 Answer 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.

  • Thanks, I'm not sure I fully understood your answer, so I added the code I was referring to. Would you mind checking it out and letting me know if you think it would work correctly, meaning that if the Financial Accounts parent was changed, the Financial Account's Relationship Team fields would correctly populate based on the new parent Account. Thanks again! Oct 10, 2012 at 14:16
  • I was able to test what you said in my sandbox and you were right, thanks again! Oct 10, 2012 at 14:20
  • Code looks fine. Though, I'd go for a more general method name, as this is not only ran at re-parenting of your child records(which is somewhat implied with 'transferRelationship'. Also runs at the initial parenting (before insert). Oct 10, 2012 at 14:24
  • Sounds good, thanks for the tip, but I think my meaning got lost in translation. It wasn't supposed to be 'Transfer Relationship', it's supposed to be 'Transfer Relationship Team from Account'. Oct 10, 2012 at 14:25
  • Oh right. I should have picked that up from the comment though. Oct 10, 2012 at 14:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .