Solution skill
Salesforce 15-char vs 18-char IDs and the checksum suffix
Complete solution
Shows how to fix salesforce 15-char vs 18-char IDs and the checksum suffix. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
The checksum exists because 15-char IDs are case-sensitive and lose information when moved through case-insensitive systems, so the 18-char form is the safe one to store and compare.
Steps
- When handling Salesforce IDs in scripts, prefer the 18-character form for storage and comparisons since the trailing 3 characters are a case-safety checksum. Validate with a format regex first, then verify the checksum on 18-char IDs before treating one as real.
When to use
You are seeing this: When handling Salesforce IDs in scripts, prefer the 18-character form for storage and comparisons since the trailing 3 characters are a case-safety checksum. Use this skill when you run into "Salesforce 15-char vs 18-char IDs and the checksum suffix".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Stack Overflow #9742913 (accepted answer, 51 votes): the asker wanted to validate Salesforce IDs and noticed they come in 15 and 18 character forms. The accepted answer (51 votes) explains the two levels: a regex for the 15 or 18 character alphanumeric format, plus a 3-character checksum appended to the 18-char form that can actually verify the ID. The checksum exists because 15-char IDs are case-sensitive and lose information when moved through case-insensitive systems, so the 18-char form is the safe one to store and compare.
Verified resolution: When handling Salesforce IDs in scripts, prefer the 18-character form for storage and comparisons since the trailing 3 characters are a case-safety checksum. Validate with a format regex first, then verify the checksum on 18-char IDs before treating one as real.
Source URL: https://stackoverflow.com/questions/9742913/validating-a-salesforce-id
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_P9jHw2VqTJcgfQLr5u_0oA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Salesforce 15-char vs 18-char IDs and the checksum suffix <span>— Vectle</span></a>