Unique Id and External Id in Salesforce
Unique Id
- Unique id is used to prevent duplicate values, which means when a value is saved on a record, then we cannot reuse or store the same values, since the values within the field should be unique.
- For example, an employee id.
There cannot be the same employee id for two employees so when we get the employee id. It should be unique so we can use the unique id option in the field.
How to enable unique id values on a field?
- click on fields and relationships of the specific object. Create a new field.
- Choose Field type.
- While creating a field the option unique is given under the required option (fig.1) enable the unique option, we can set case sensitive option unique value.
- After enabling the unique option make sure to save.
- When the field is filled with a duplicate value it pops up an error message. and will not let the record be saved until a unique value is given.
External Id
- External Id is a custom field that contains external attributes, such as external unique record identifiers.
- An object can contain 25 external Id.
- Field types that support external Id
1)Text
2) Number
3)Email
How to create an External Id field.
Object → Custom Fields and Relationships → click New → check the External id check box.
- Create a new field in fields and relationships by clicking on new.
- Choose the field type.
- Fill in the necessary details.
- Then check the External Id box and make sure to save.