Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
13 votes
Accepted

How do I find merged Records?

In the immediate aftermath (and a short time thereafter), you can find deleted records with a MasterRecordId in the Recycle Bin. SELECT MasterRecordId FROM Account WHERE MasterRecordId != null ALL ...
Adrian Larson's user avatar
  • 150k
8 votes
Accepted

Account Merge Trigger Execution Order

From the Apex Developer Guide Triggers and Merge Statements Merge events do not fire their own trigger events. Instead, they fire delete and update events as follows: Deletion of losing ...
Ralph Callaway's user avatar
8 votes

DML Merge Fails INVALID_FIELD_FOR_INSERT_UPDATE

I'm not sure why, but the merge statement appears to be sensitive to the fields that are in memory for an sObject when passed to the merge statement. The operation fails if any of the fields are not ...
Ralph Callaway's user avatar
7 votes
Accepted

Merging records in bulk

This is a rather old-school method of merging duplicates. We built a better system in our org that simply queries the DuplicateRecordSet table for duplicates and merges them. Actual deduplication ...
sfdcfox's user avatar
  • 494k
6 votes
Accepted

Merge DML Operation in Apex: why do blank fields of the master record supersede?

As documented here the master record always supersedes field values of the other records. Practically I needed my own merge-logic and merge-UI because of the limitations of the default merge ...
Uwe Heim's user avatar
  • 28.4k
5 votes
Accepted

Merging Docx files into one - Apex

Aside from plain text files (e.g. source code or README.TXT type files), most files follow an internal structure. This means that two similar files (e.g. two GIF or DOCX) being "added together&...
sfdcfox's user avatar
  • 494k
4 votes
Accepted

Automation on lead merge

Using the after delete trigger via MasterRecordId is documented to be the only way to trigger on a merge: If your application requires special handling for deleted records that occur as a result of ...
David Reed's user avatar
  • 93.1k
4 votes
Accepted

How to merge methods into one

You can merge the two methods into one like this way. public static void updateTableMergeMethod(Map<Id, Team__c> newTeams, Map<Id, Team__c> oldTeams) { Set<Id> ...
Santanu Boral's user avatar
4 votes

How to implement my de-dupe code into batch apex?

You can reduce your DML statements by up to half by using the alternative format for merge, which takes a single record and two related records: Account master = dups.remove(0); Account[] children = ...
sfdcfox's user avatar
  • 494k
4 votes

Apex trigger to stop duplicate records into SF if email already exists on a person account

Yes, we can add more complicated logic in a trigger. Traditionally, we offload the trigger logic in to a "trigger handler" class, as demonstrated in this answer. However, to keep things simple, this ...
sfdcfox's user avatar
  • 494k
4 votes
Accepted

Merging two lists into one

At the very least, you would want to store the results of one of your queries in a map. Given a public Map<String, Object> myMap {get; set;} in a controller or controller extension, you can ...
Derek F's user avatar
  • 62.1k
4 votes
Accepted

Cleaner way to filter specific object ids from List <String>?

What you have already looks good. The only optimization I see is you can just compare the token directly, you don't need String.valueOf. if (Id.valueOf(s).getSObjectType() == UsefulObject__c....
Adrian Larson's user avatar
  • 150k
3 votes

DML Merge Fails INVALID_FIELD_FOR_INSERT_UPDATE

Props to @ralphcallaway as his answer saved me some time. Here's an expanded answer re: fields in memory and their impact on merge verb Imagine you have: Contact winner; Contact loser; makeMergeReady(...
cropredy's user avatar
  • 71.8k
3 votes
Accepted

How to implement my de-dupe code into batch apex?

If you're just using an anonymous script and trying to knock this task out quickly, you can add a limits check and just bail once you've performed the maximum number of DML Statements. for (...) { ...
Adrian Larson's user avatar
  • 150k
3 votes

Unable to merge the custom records in salesforce

Salesforce will allow you to use merge operation on Account, Contact, and Lead. As of now, I am not entirely sure if SF is supporting the merge of custom object records. It appears from this Idea ...
TSmith's user avatar
  • 5,032
3 votes

Merging pdf attachments

PDF is a binary format that, like most binary formats, simply can't be squashed together directly. It contains magic headers, object graphs, images, compression, and a bunch of other stuff that you ...
sfdcfox's user avatar
  • 494k
3 votes
Accepted

On what criteria Merge Accounts auto select the Master Record

The default master record is the oldest record, but you can change it.
Torsen's user avatar
  • 1,534
3 votes
Accepted

Merging contacts does not swap the Order.BilltoContactId or Order.ShiptoContactId

So frustrating when SFDC OOTB features don't work on standard objects This is a Known Issue and I encourage you to indicate it 'affects you' The workaround in the KI is unpleasant if you have an ...
cropredy's user avatar
  • 71.8k
3 votes
Accepted

Unable to Create/Update Fields CreatedDate - Database.Merge Leads

Since you queried the CreatedDate field, Salesforce is trying to set the field value on merge, which it can't, because the field can't be modified. Remove the CreatedDate field from your query. ...
sfdcfox's user avatar
  • 494k
3 votes
Accepted

How to control the fields displayed on Contact merge

Most fields are only displayed if they have a value in them (contact information such as emails and phones are always shown). Fields are made editable only if the user has Edit access to the field and ...
sfdcfox's user avatar
  • 494k
3 votes
Accepted

Dataloader = CSV = Numbers = Scientific Notation

If you are using Dataloader, I believe, that's the best option (You are already doing it). DON'T open the file at all. You can try ETL tools, such as Informatica , Jitterbit etc
Amit Sahu's user avatar
  • 141
3 votes
Accepted

Can I use SOSL to identify all records with a certain lookup value?

Unfortunately, doing that in SOSL isn't going to work very easily. The best alternative for the future would be to have periodic backups for issues like this. However, doing this in Apex is trivial: ...
sfdcfox's user avatar
  • 494k
2 votes

Is there a way of merging two or more data extensions in Exact Target?

Yes, with a Query Activity. select emailAddress from DataExtension1 union select emailaddress from DataExtension2 /* add additional unions here */ /* target: MasterDataExtension */ /* action: ...
Adam Spriggs's user avatar
  • 30.7k
2 votes
Accepted

Merging duplicate accounts in Apex - Governor limits

You certainly are missing the point of the batch. Query the records you want to merge in your start method, not your execute method. By doing so, you then control how many records you pass to each ...
Adrian Larson's user avatar
  • 150k
2 votes
Accepted

problem merge record in multiselect picklist in visualforce and apex class

public LIST<SelectOption> getallEmployee(){ LIST<HREMPINFO__c> empMember = [SELECT Id, Name, Full_Name__r.Name FROM HREMPINFO__c WHERE Id IN (...
Vickal's user avatar
  • 592
2 votes

How do I find merged Records?

If you are using AccountHistory, then very easy to do from AccountHistory table with out worrying about recycle bin. SELECT AccountId where Field = 'accountMerged'
hamayoun's user avatar
  • 2,777
2 votes
Accepted

Why fire only two triggers on merge?

Children triggers never fire by default on any operation (update, delete, undelete, or merge). If you want/need these records to be triggered, you need to call those actions manually. The system is ...
sfdcfox's user avatar
  • 494k
2 votes

Merging subscriberkeys and records

There is no way to 'merge' subscribers. Every individual Contact with a unqiue Subscriber Key also had system defined attributes which can only be changed by Salesforce Service Team and requires their ...
Rain's user avatar
  • 5,775
2 votes

Unable to merge the custom records in salesforce

There are only 3 objects that support merge: Account, Contact, and Lead. See here, under "Merging Considerations"
HungryBeagle's user avatar
2 votes
Accepted

What does merging duplicate Leads/Contacts/Account do at the record and related record level?

Do the merge-from records get deleted? Yes, they are moved to the Recycle Bin (which can as of yet only be seen in Classic). Do the related list records get moved to the merge-to record, even ...
sfdcfox's user avatar
  • 494k

Only top scored, non community-wiki answers of a minimum length are eligible