I was working with someone recently who saw how I converted 15 character IDs to 18 character IDs in Apex and thought it was clever. I always thought it was something everyone knew, but just in case, I’m posting it.

All I am doing is using the ID datatype, which does it for you automatically. You just have to trap the StringException in case you get passed a string that isn’t an ID. Anyone else do it another way?

string s = '0013000000K7WW2';
try{
ID sID = s;
// if we get here, it's a valid ID and the sID field is an 18 character one
} catch (System.StringException e){
// if it goes here, it's not an ID. Do something if you need to.
}

Cool! On a side note I’ve been hunting for ages for the formula to convert the 15 and 18 char IDs. I know I watched how to do it in the iTunes training videos but have no idea which one… you don’t happen to know what it is?

I have Excel Connector installed, and I can convert 15 character IDs to 18 character IDs using =FIXID(cell reference). However, I have a column with almost 100,000 rows and =FIXID seems to work only for cells lower than row 65,536. Anything above returns a #VALUE error. I’m using Excel 2007. Any workaround other than splitting the list into two?