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
ZTZT 

Slash in <apex:outputLink> syntax

Could someone explain why the slash "/' is required for the link to work in the example below?

 

When I use this  code, the link does not work. I get an error: "The name '...' can only contain alphanumeric characters, must begin with a letter, and must be unique."

 

<apex:column headerValue="Contract Number">
<apex:outputLink value="{!c.Id}">{!c.ContractNumber}</apex:outputLink>
</apex:column>

 

However when I add the slash "/" everything works as expected. Is this documented somewhere? I have not found an explanation yet.

 

<apex:column headerValue="Contract Number">
<apex:outputLink value="/{!c.Id}">{!c.ContractNumber}</apex:outputLink>
</apex:column>

Best Answer chosen by Admin (Salesforce Developers) 
ajmerakavitaajmerakavita

Its an output link where you want to get redirected to salesforce page.

Hence when you just specify "{!c.Id}" it does not tell you the URL.

While when you write "/{!c.Id}" it means take the URL of current salesforce instance and append the ID parameter.

Hence this would result in http://...salesforce instance/the record Id. and hence it opens the correct page for you.

All Answers

ajmerakavitaajmerakavita

Its an output link where you want to get redirected to salesforce page.

Hence when you just specify "{!c.Id}" it does not tell you the URL.

While when you write "/{!c.Id}" it means take the URL of current salesforce instance and append the ID parameter.

Hence this would result in http://...salesforce instance/the record Id. and hence it opens the correct page for you.

This was selected as the best answer
ZTZT

Thank you for the explanation. It makes sense. It is what I observed in the URL.