Skip to content

Instantly share code, notes, and snippets.

@LucasMaloney
Created April 22, 2016 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucasMaloney/11f907b0126ed528296cf0a66c512c21 to your computer and use it in GitHub Desktop.
Save LucasMaloney/11f907b0126ed528296cf0a66c512c21 to your computer and use it in GitHub Desktop.
// Generates "case safe" versions Salesforce record ids
let flagsToChar flags = if flags < 26 then 'A' + (char flags) else '0' + (char (flags - 26))
let getCaseFlag id i j = if Char.IsUpper(id, i * 5 + j) then 1 <<< j else 0
let getCaseChar id i =
Seq.init 5 (getCaseFlag id i)
|> Seq.sum
|> flagsToChar
let getCaseSuffix id =
Seq.init 3 (getCaseChar id)
|> String.Concat
let getCaseSafeId id = id + (getCaseSuffix id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment