Loading

Create 18-character record ID with custom formula field

Publiceringsdatum: Dec 27, 2024
Beskrivning
Create an 18-character record ID using a custom formula field due to the following limitations:
 
  1. User object cannot create workflow -> field update
  2. There is a maximum number of formula characters in each custom formula field.

Admin hasn't been able to create User ID (18-digits) in Salesforce for reporting purpose.

It returns below error when using the single formula directly under custom formula field.
 
'Error: Compiled formula is too big to execute (7,771 characters). Maximum size is 5,000 characters.'

Note: To do the reverse and change any 18-character Salesforce.com record ID to 15-characters, just remove the 3 characters on the far right of the longer string.
Lösning

Create a formula field with return data type Text and the following as its formula. The field can be called “Record ID 18-char” or whatever else you choose.


Id &

MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(Id,1,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(Id,2,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(Id,3,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(Id,4,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(Id,5,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)

&

MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(Id,6,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(Id,7,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(Id,8,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(Id,9,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(Id,10,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)

&

MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(Id,11,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(Id,12,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(Id,13,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(Id,14,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(Id,15,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)



See also:
Build a Formula Field
More Information about Record IDs: https://help.salesforce.com/articleView?id=000324394&language=en_US&type=1&mode=1
Knowledge-artikelnummer

000385585

 
Laddar
Salesforce Help | Article