0
votes

So I am trying to get the current users User License eg. System Administrator or User etc... I have look through here and used other methods however these don't seem to work for me. I was wondering where I could make a start towards this?

The error I get is:

Comparison arguments must be compatible types: Schema.SObjectField, String

From using the following code:

public String getOpps() {
    if(Profile.UserLicense.Name === 'Community Customer') {
        oppCheck = true;
    } else {
        oppCheck = false;
    }


    ***loop*** {
            code here
        }
    } else {
       more code here
    }
    return 'nil';
 }
1
Just to clarify, System Administrator vs User is a profile, not a user license. A license determines things like Salesforce vs Chatter. - Egor

1 Answers

0
votes

These are the license types, I got them from the API guide here thanks to this post.

  • Standard: user license. This user type also includes Salesforce Platform and Salesforce Platform One user licenses. Label is Standard.
  • PowerPartner: PRM user whose access is limited because he or she is a partner and typically accesses the application through a partner portal. Label is Partner.
  • CSPLitePortal: user whose access is limited because he or she is an organization's customer and accesses the application through aCustomer Portal. Label is High Volume Portal.
  • CustomerSuccess: user whose access is limited because he or she is an organization's customer and accesses the application through a Customer Portal. Label is Customer Portal User.
  • PowerCustomerSuccess: user whose access is limited because he or she is an organization's customer and accesses the application through a Customer Portal. Label is Customer Portal Manager. Users with this license type can view and edit data they directly own or data owned by or shared with users below them in the Customer Portal role hierarchy.
  • CsnOnly: user whose access to the application is limited to Chatter. This user type includes Chatter Free and Chatter moderator users. Label is Chatter Free.

Also, you might have some luck trying:

Profile p = [Select Name from Profile where Id =: userinfo.getProfileid()];
String pname = p.name;

if(pname == 'Community Customer') {
    oppCheck = true;
} else {
    oppCheck = false;
}