I cannot seem to find the documentation anywhere about this doubt. Whenever and wherever I call "Userinfo.getUserId()" method in the transaction, will it always return 18 digit user ID to me? or it varies?

1 Answer 1


From my observation, UserInfo.getUserId should always return an 18-character ID. However, the return type is "String" for this method, so there is no guarantee that the return value will always be the 18-character ID format. However, you can guarantee that an ID will always be 18-characters if you use the Id data type:

Id userId = UserInfo.getUserId();

This works because the Id type automatically validates the String is a valid ID and automatically calculates the parity bits for the ID (the last three characters).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .