+ Start a Discussion
EIE50EIE50 

Get customer portal url dynamically in apex class

Hi,

 

I have a webservice class in which i am consturcting url for customer portal users. I've hard coded the customer portal url all these days and now i want to make it dynamic so that i need not make changes to the class when ever i refresh my sandbox with sandbox portal urls. This is what the url looks like now,

 

https://na1.salesforce.com/secur/login_portal.jsp?orgId=xxxxxxxxxxxxx&portalId=xxxxxxxxxxxxxxx;

 What i want is, i need to know how to get the portal url, org id and portal id dynamically in my apex class and construct a url of above format.

 

Any methods/ pointers/ code snippets are appreciated.

 

Thanks.

 

 

 

 

TejTej

UserInfo.getOrganizationId you can try this one for org id or

 

put both of those id's in a custom settings and use them in your class, you can change them based on the environment.

EIE50EIE50

I dont want any maintenance to be done by admins.

 

With custom settings, anyways admins need to change it for each sanbox refresh. So i wouldnt want to take this route.

 

Any other solutions?

 

Thanks.