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
johannjohann 

finding the name of a Partner Portal (or a Customer Portal) from within apex code

For Sites development, there's a Site object with a getName() method that lets you dynamically get the name of the site in which your code is running, which is useful if you have some apex code that runs in the context of multiple sites but might need to do something slightly different depending on context.

 

There does not appear to be an equivalent method for code running in either the Customer or Partner Portal, and the method on the Site object returns and empty string. 

 

Does anyone know of how to find the name of the portal in which one's code is running?  (basically, you want to ask the Saleforce Context, "hey, what portal am I being accessed through?")

Pan_AKPan_AK

Hi

 

The Standard Object  UserRole have field PortalType which can give you name of the portal in 

which once's code is running you can use the following link for the UserRole Object .

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_role.htm .

 

And in the following query will help you

 

Select u.PortalType From UserRole u

 

Please tick the Answer if it solve your query

johannjohann

Thanks for the response.  That method will give you the TYPE of portal (customer or partner) but it won't give you the NAME of the specific portal.  

 

Let's say, for instance, you have 2 different Partner Portals named "Regular Partner" and "Preferred Partner" and you want to share some code between the portals, but it needs to be able to tell WHICH portal it's running in so that it can display a different level of detail depending on the name of the Portal.  I'm looking for the way of find that name "Preferred Partner"  from the code running in that portal (or the Id of the Portal would work too).  

 

If it were a Sites page, I would just call Site.getName() but I can't find the portal equivalent.