Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full ID entry
How-to guide

Work with Salesforce IDs effectively

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.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 19, 2026

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.

  1. 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.

  2. 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.

  3. 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', ...).

  4. 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.

  5. 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.

  6. 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.

  7. 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.

Key options
15-character IDremember

Native case-sensitive format. The platform's internal representation.

18-character IDremember

15-character with 3-character checksum suffix. Safe for case-insensitive systems.

Object prefixremember

First 3 characters identifying the sObject type. Stable across orgs for standard objects.

External ID fieldremember

Custom field marked as External ID. Separate matching key for integration scenarios; not a Salesforce ID.

ID type in Apexremember

Strongly typed Id class in Apex. Conversions to/from String supported through valueOf() and toString().

Gotchas
  • 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.

See the full ID entry

ID includes the definition, worked example, deep dive, related terms, and a quiz.