What is an external ID in Salesforce?

When importing custom objects, solutions, or person accounts, you can use external IDs to prevent duplicate records from being created as a result of the import operation. An external ID is a custom field that has the “External ID” attribute, meaning that it contains unique record identifiers from a system outside of Salesforce. When you select this option, the import wizard will detect existing records in Salesforce that have the same external ID. Note that this operation is not case-sensitive - for example, “ABC” will be matched with “abc”. However, there is an exception: if the custom field has the separate “Unique” attribute and the case-sensitive option for that attribute is selected, uppercase and lowercase letters will not be considered identical.

The fields with below data types can only be external Id

1. Number
2. Text
3. Email

When a field is made as external Id, the field will be automatically indexed. Additionally, if you have an external ID field, the field becomes searchable in the sidebar search. You also can use the upsert API call with the extenal ID to refer to records.

If we create External Id field, it will be indexed by default by Salesforce.

During upsert operation,

1. If External Ids are matched, it will update the record.

2. If External Ids are not matched, it will create a new record.

3. If External Ids are matched more than once, it will throw an error.

How to set a field as External Id field?