Skip to content
  • 799thecoder@gmail.com
799 The Coder

A Passionate Coder

  • Home
  • Apex
  • Lightning
  • Salesforce Excel
  • About
  • Contact

Tag Archives: Account Merge

  • Home   /  
  • Posts tagged "Account Merge"
799 The Coder Apex Code,Apex Trigger Account, Account Merge, Account Team Member

Salesforce Account Merge without Account Team Member records

Before we go ahead we should know about standard functionality of Account Merge Click Here.

Account Merge behavior for Account team member records : If both accounts have different account teams, the merged account will contain members from both account teams.

Here standard behavior will put all team members of both account under the merged account.What if you don’t want to bring account team members of the other account ?

So basically when we are merging two accounts one gets deleted and another gets updated. We can write a trigger on the Delete event of account, whenever an account is going to be deleted we will also delete its team members. The code snippet for stopping copying of account team members of losing account to the winning account is as follows.

Delete Account Team Members before Merge
1
2
3
4
5
6
7
8
9
10
11
12
if(Trigger.isBefore && Trigger.isDelete){
// Collecting all Team members to delete
List accTeamMemberToDelete = new List();
for(account acc : [SELECT id,(SELECT id FROM AccountTeamMembers) FROM account WHERE id IN :Trigger.old]){
if(acc.AccountTeamMembers != null){
accTeamMemberToDelete.addAll(acc.AccountTeamMembers);
}
}
if(accTeamMemberToDelete.size() > 0){
delete accTeamMemberToDelete;
}
}

Books for Salesforce Developers

Best Books for C Language

Search Here

Recent Posts

  • Sobject Records in various Trigger Events January 28, 2020
  • Apex Trigger’s New Design October 23, 2019
  • Salesforce Spring ’19 Release Notes for Apex Trigger.operationType February 21, 2019
  • Share Lightning Notes and Attachments with Community Users January 7, 2019
  • Using Variable for Static Resource September 7, 2017

Categories

  • Apex Code (19)
  • Apex Trigger (5)
  • C/C++ (6)
  • Excel (5)
  • Javascript (3)
  • jQuery (2)
  • Lightning (2)
  • Other (2)
  • Salesforce (16)
  • Visualforce Page (6)

Archives

799 The Coder

Facebook By Weblizar Powered By Weblizar

Get New Post Update !

Popular Tags

Account Account Merge Account Team Member All Number Conversion Apex apex:actionFunction apex:actionRegion Apex:enhancedList Apex Trigger Apex Trigger Update C C - Guess the word C Authentication C Small Project Datetime Datetime literal SOQL Datetime on Visualforce Default New User License of Customer Portal DescribeFieldResult Disable Inline Editing Apex:enhancedList Excel CORREL Function in Apex Excel CORREL method in apex Excel function in Apex Excel INTERCEPT method in salesforce Excel LINEST function in Apex Excel method Formatting Datetime Objects in VisualForce Integer Part Length INTERCEPT function in apex INTERCEPT function in salesforce INTERCEPT method in apex Love and Friendship calculator Number To Word Converter Number Type Field Apex Overlapping Logic Overlapping pseudo code Pyramid Using C Salesforce Service Console Salesforce setTabIcon setTabStyle SOQL Datetime SOQL Datetime Literal Javascript Trigger OperationType visualforce datetime format

Social Profiles

© Copyright 2015-2019 799 The Coder | A passionate coder