function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
FolderProduction OrgFolderProduction Org 

Which method can replace UserInfo.isCurrentUserLicensed?

Hi all,
I try to upgrade my old Util class to api 46 this morning. But I face this issue.

User-added image

I try found this changes in Release Note but anything applied, and I also can found this method at this link:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_userinfo.htm

Did anyone face this issue? Which method can replace UserInfo.isCurrentUserLicensed under API 46.

Best wishes,

Lee

FolderProduction OrgFolderProduction Org
Hi all,

This is my test code :
public class TestCode {
    public Boolean isLicensed(String license){
        return UserInfo.isCurrentUserLicensed(license);
    }
}

Best wishes,
Lee
KapilCKapilC
Hi Lee,

Please find the code below.
public class TestCode {
    public Boolean isLicensed(String license){
        boolean isFound = false;
        for(profile p : [SELECT UserLicenseId FROM Profile where id=:userinfo.getProfileId()]){
               for(UserLicense ul : [SELECT Name FROM UserLicense where id=:p.UserLicenseId]){
                    isFound = license == ul.Name?true:false;
                }
        }
        return isFound;
	}
}

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Regards,
Kapil
(forcecube@gmail.com)
 
Ajay K DubediAjay K Dubedi
Hi,

I hope you are doing well but I also found this problem in my Org with API version 46.
Maybe it will not be updated in salesforce. For now, you can use API version 46.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi