Getting “Default New User License” of customer portal in apex code.

Sometime we need to get Default New User License of Customer Portal in the apex code, After doing some google search, I found that there is no direct method or way to do it in the apex.

To get the Default New User License of customer portal in apex code, we need either customer portal name or site name. Below are the steps for Getting “Default New User License” of customer portal in apex code. Here you go :-

Getting Default New User License of Customer Portal in Code

STEP 1 : You need MetadataService.cls Apex class in your salesforce org.(I would suggest keep only required methods of your need only, as this class has huge lines of code).
STEP 2 : Now you need to set Remote Site Setting. Setting up remote site setting is shown in below figures.

Setup Remote Site Setting
Setup Remote Site Setting
Setup Remote Site Setting for VF Page.
Setup Remote Site Setting for VF page.

STEP 3 : After setting up MetaDataService apex class and remote site setting we are ready to read “Default New User License” of customer portal in apex code. Given below is the code snippet for this.

1 thought on “Getting “Default New User License” of customer portal in apex code.”

Leave a Reply

Your email address will not be published. Required fields are marked *