Tags
If you want to access User license field which determines the type of license that user is on(ex: Salesforce, Salesforce Platform etc), you can access it in apex as follows:
Suppose, you want to create a validation rule in User object to make a custom field mandatory based on the license, it could be as follows,substitute Customfield with the actual field name(API name):
AND(ISNEW(),ISBLANK(Customfield), OR(Profile.UserLicense.Name=’Salesforce’,Profile.UserLicense.Name=’Salesforce Platform’)
User.Profile.UserLicense.Name