+ Start a Discussion
RustyboyRustyboy 

Calculate remaining licences using apex

We need to create SF users in VF and Apex, and I want to show the users a count of how many remaining licences they have.

Is there any way of finding this out using Apex?
Best Answer chosen by Rustyboy
Martijn SchwarzerMartijn Schwarzer
Hi Rustyboy,

At this time this is not possible using SOQL. You  can use screen scraping to get the info, but the best way is to vote for this idea:

https://success.salesforce.com/ideaView?id=08730000000cJTEAA2

Screen scraping can be done like this:
PageReference pr=new PageReference('/' + UserInfo.getOrganisationId()); 
String rawData=pr.getContent().toString();

The info you need is in the table contained in the div with id that contains "RelatedUserLicenseList".

Hope this helps!

Best regards,
Martijn Schwärzer

All Answers

Martijn SchwarzerMartijn Schwarzer
Hi Rustyboy,

At this time this is not possible using SOQL. You  can use screen scraping to get the info, but the best way is to vote for this idea:

https://success.salesforce.com/ideaView?id=08730000000cJTEAA2

Screen scraping can be done like this:
PageReference pr=new PageReference('/' + UserInfo.getOrganisationId()); 
String rawData=pr.getContent().toString();

The info you need is in the table contained in the div with id that contains "RelatedUserLicenseList".

Hope this helps!

Best regards,
Martijn Schwärzer
This was selected as the best answer
RustyboyRustyboy
Thanks Martin