+ Start a Discussion
studebakerstudebaker 

URLFOR in Sites

My Sites application i intended for intranet use (say, 1000 users). Of those 1000 users, only 100 have salesforce user IDs.

 

I want to put a link on the VF page that says "New Account (salesforce user id required)" and have that link, if clicked, open a new browser tab/window to the new Account (non VF) page.

 

I thought I could do the following:

 

<apex:outputLink target="_blank" value="{!URLFOR($Action.Account.New)}">New Account (salesforce user id required)</apex:outputLink>

but this generates a URL of the form:

 

http://myDomain.sandbox.cs3.force.com/mySite/001/e?retURL=/mySite/apex/myVFpage

 Clearly this doesn't work as the generated URL should be either:

 

  • https://cs3.salesforce.com/001/e (if I'm executing in Sandbox)
  • https://na5.salesforce.com/001/e (if I'm executing in Prod)
While I could create these URLs in the controller and make them available to the outputlink component, I'd have to write logic that hardcoded the URL to the Org ID which isn't very portable.
 
Any ideas here? 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
BulentBulent

With force.com sites you can only make visualforce pages public. Only souple of sandard pages can be enabled for sites but they are mainly for public ideas use cases.

so, when you put a link for a standard page, site will say this is a valid page but it' not enabled for sites, then will display the authorization required page.

 

If your site is tied to a portal then the authorization required page will also display the login component. However, this login is for portal and not for employees to login to saleforce.com

 

so in your scenario you really need to put a fully qualified url (so that you won't be in site context) and the link will take users to the salesforce login and the target page after the login.