// Verbose String sObjectPrefix = '0Af'; Id sObjectId = Id.valueOf(sObjectPrefix.rightPad(15, '0')); SObjectType sot = sObjectId.getSObjectType(); System.debug(sot); // Single line (thanks to Adrian Larson on SO) System.debug(Id.valueOf('0Af'.rightPad(15, '0')).getSObjectType());
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter