How to get User License Name from User object in Salesforce?

How to get User License Name from User object in Salesforce?

Sample SOQL using Apex:

for ( User objUser : [ SELECT Id, Name, Profile.UserLicense.Name FROM User WHERE Profile.UserLicenseId != null ] )
    system.debug( objUser.Profile.UserLicense.Name );
 
Output:

Leave a Reply