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
chirugantachiruganta 

How to get list of user licenses in apex to show on VF page

I need help on showing list of user licences in Visualforce Page. Is this possible? If yes, please send me the steps to follow.
Best Answer chosen by chiruganta
gokul bharatigokul bharati
Hi ,

Please find the snippet:

VF Page:
<apex:page controller="ListOFuserLicenses"> <apex:repeat value="{!ListOfUserLicences}" var="usl"> <apex:outputText value="{!usl}"/> <br/> </apex:repeat> </apex:page>

Class:

public class ListOFuserLicenses {

public List<String>getListOfUserLicences(){
List<string> Lt=new list<string>();
for(UserLicense a:[SELECT Name FROM UserLicense]){
lt.add(a.Name);
}
return lt;
}
}

All Answers

gokul bharatigokul bharati
Hi ,

Please find the snippet:

VF Page:
<apex:page controller="ListOFuserLicenses"> <apex:repeat value="{!ListOfUserLicences}" var="usl"> <apex:outputText value="{!usl}"/> <br/> </apex:repeat> </apex:page>

Class:

public class ListOFuserLicenses {

public List<String>getListOfUserLicences(){
List<string> Lt=new list<string>();
for(UserLicense a:[SELECT Name FROM UserLicense]){
lt.add(a.Name);
}
return lt;
}
}
This was selected as the best answer
chirugantachiruganta
Thanks for the reply Gokul. I tried this and it is working good. I need to use fields TotalLicenses and UsedLicenses. But it is not allowing me to use those fields in query. Please help me on this
raj kiranraj kiran
HI Chiruganta,

Have you found any approach for this question?
I am too trying to get the total count of used license and unused license in the org. not luck for so far.

Please let me know if there is any .