Working with Salesforce IDs is mostly a debugging skill rather than a configuration task. The steps below cover the common scenarios where understanding ID structure matters.
- Identify the object type from an ID
Take the first three characters of the ID. Match against the prefix list (001 = Account, 003 = Contact, etc.) or query Schema.SObjectType in Apex with the prefix.
- Convert 15 to 18 character ID
Use the standard Excel formula or the Apex Id.toString() method. APIs already return 18-character IDs; this is mostly for legacy data sources.
- Query records by ID
SOQL: SELECT Fields FROM Object WHERE Id = '<id>'. Both 15 and 18 character IDs work. Bulk: WHERE Id IN ('id1', 'id2', ...).
- Audit ID handling in integrations
For any integration touching IDs, confirm 18-character format is used. CSV files and Excel sheets especially need 18-character IDs to avoid case-sensitivity bugs.
- Trace ID through audit logs
Setup Audit Trail, EmailMessage, and most history objects reference records by ID. Use the ID to trace a record's lifecycle across audit data.
- Find records when only partial ID is known
Use the prefix filter: SELECT Id FROM <object> WHERE Id LIKE '<prefix>%'. Useful when an ID was truncated and you need to find the full one.
- Document custom object prefixes
Maintain a quick-reference doc mapping custom object prefixes to object names. New admins inheriting the org will appreciate the cheat sheet.
Native case-sensitive format. The platform's internal representation.
15-character with 3-character checksum suffix. Safe for case-insensitive systems.
First 3 characters identifying the sObject type. Stable across orgs for standard objects.
Custom field marked as External ID. Separate matching key for integration scenarios; not a Salesforce ID.
Strongly typed Id class in Apex. Conversions to/from String supported through valueOf() and toString().
- 15-character IDs are case-sensitive. Storing them in case-insensitive systems (Excel, some databases) produces silent match failures. Always use 18-character for those systems.
- URL truncation through email or chat can drop trailing characters. The 18-character format includes a checksum which lets you detect truncation; 15-character does not.
- IDs are not reusable. Deleting a record does not free its ID for future use; the ID stays in audit trails forever.
- The 3-character prefix is per-object but the same across orgs for standard objects. Custom object prefixes are stable within an org but may differ between orgs.
- Apex Id type is strict. Passing a String where Id is expected produces a compile error; always use valueOf() to convert explicitly.