Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- Creating Salesforce Links in VisualForce Email Tem...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-15-2011 10:31 AM
Wow, I just can't seem to figure this simple thing out. In a visualforce template I want to create a link to an object record.
I've seen examples like this
({!LEFT($Api.Partner_Server_URL_140, FIND(".com/",$Api.Partner_Server_URL_140)+3)
but shouldn't I be able to use a simple relative URL to get this to work?
A new record was created! <a href="/{!RelatedTo.ID}">Click here</a> to see it.
However, when the email gets sent out the link becomes "http://5008000000dmoskaax/" and not "http://na8.salesforce.com/5008000000dmoskaax"
Any idears?
Tyler
Solved! Go to Solution.
Re: Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-15-2011 10:36 AM
Relative URLs only make sense in the context of a web server - i.e. they are relative to the root of the server. A relative URL in an email doesn't have a root so it is assumed to be an absolute URL.
The formula based on the partner server url is the only way I've found to achieve this.
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.
Re: Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-15-2011 10:37 AM
Does it work in the preview before sending the email? I copied and pasted your example and that works for me - but when it sends, it looses the 'context' - so my guess is that you'll have to hardcode the beginning of the URL (or use some nifty way of generating it that I can't think of offhand)...
Re: Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-15-2011 10:41 AM
It does work in preview but as Bob Buzzard said the email has no server context. The server partner url code I pasted above had some comments about links breaking in special cases such as european users vs american users. I was hoping there was a clean way to do this as it is pretty crucial and used over and over again. Alas.
Re: Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-03-2011 12:20 PM
Can someone explain w
bob_buzzard wrote:Relative URLs only make sense in the context of a web server - i.e. they are relative to the root of the server. A relative URL in an email doesn't have a root so it is assumed to be an absolute URL.
The formula based on the partner server url is the only way I've found to achieve this.
Can someone explain what this "formula" is?
Re: Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-05-2011 05:52 AM
I hacked around with that formulate to get a complete syntax that actualy works in the email template--
<apex:outputlink value="{!LEFT($Api.Partner_Server_URL_140,FIND('.c
You need to use single quotes in the expressions within the value attribute so as not to confuse the double-quotes that delimit it.
I used 4 unlike the +3 so I got the "/".
Re: Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-06-2012 01:41 PM
Ken - I know this is an old post, but I was playing around with similar functionality and could not get it straight... In searching I came across this post. The line you posted worked great and I learned a little something. Thank you for posting.
Re: Creating Salesforce Links in VisualForc e Email Templates
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-06-2012 01:44 PM
Glad I could help. It's always neat learning other peoples' tricks. And SF is a bit of a maverick environment so it helps.
-Ken

