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
MWelch_WTMWelch_WT 

Getting Sites URL in Apex.

I need to get the the site-wide URL for Sites (xxxxxx.force.com) in Apex, in order to send and email with a link to a Sites site. Is there a way to do this? I could hard code it, but this will be for a managed package.

 

Bonus points if you  can tell me how to get the server (na3, na6, na7, etc) from within a Sites site, so that a "contact us" form can send an email to a User.

BulentBulent

getCurrentSiteUrl

 

the full list of site apex methods and site visualforce expressions are listed in the online help

Why do you need the instance name?  

Message Edited by Bulent on 11-12-2009 05:56 PM
MWelch_WTMWelch_WT

As far as I can tell, getCurrentSiteUrl only works in the Sites context.  That is, when the Apex code executing that command is the controller for a Sites page. I need to get the Sites domain name from within standard salesforce.

 

This is the flow:

 

1: User goes to VF page, selects some items to email links to customers, and sends them.

2: VF page controller generates the email, with a link to the Sites page. (Here's where I need to get the Sites domain name.)

3: Customer receives email, clicks on link to go to Sites.

4: Customer can send feedback by clicking a button.

5: Sites VF page controller then sends an email to original SFDC user, with a link to an internal page to review the customer's feedback. (Here's where it would be nice to get the instance name, so the email could say "Click here" and send the User to https://na7.salesforce.com/apex/CustomerFeedback, for instance.)

 

Thanks. 

BulentBulent

I see. There is a pilot feature that allows you to create workflow alerts based on daily limits usage. That feature also enables site fields to be accessed via API. If you are interested in participating the pilot please send me an email.

 

But keep in mind on Enterprise and Unlimited editions you can create up to 25 sites. So the user needs to pick the correct site on the UI. 

 

for the second part URLFOR() should work.