External Key in Salesforce
External Key is a very interesting and important feature given by Salesforce. It is very much helpful when we are importing some data from legacy system, means suppose the data in the old system needs to be migrated to salesforce and we want to avoid importing any duplicate records from that system into salesforce.
Then, how salesforce will come to know that on which basis, it should differentiate between the records being imported from external system.
For this purpose, we can define some field from legacy data that will act as unique identifier in salesforce and we can map that field with a custom field in salesforce that has attribute External Id true. So, whenever we will import data from legacy system, salesforce won’t allow any duplicate record based on the external id defined for that object.
We can define 3 external Ids for every object, and only three data types are allowed to be used in external id. These are (Email, text, number).
So, for example there are some records existing in external system. Please see the screenshot below:
Suppose these are records in external system and needs to be imported in salesforce and you want that duplicate records should not be imported in salesforce. So, we need to define some field on basis of which salesforce can decide which record is duplicate and which is not. So, in above screenshot we have picked Type to be an external id. Hence, salesforce won’t allow all the records highlighted in black border in the snapshot above because it will categorize them as duplicate record because one record with that particular Type value has already been imported(highlighted in red).
That is the importance of external Id while integrating with external systems. If you are working with external system, external id will become your best friend.