1

I am outputting a table from a list in my controller using apex:repeat.

In one of my columns, I want to have a link that will open the record for detail view

I want a link like this https://www.salesforce.com/apex/SystemChangeRequest?id=a3K8E0000000B7S.

as my detail page is called SystemChangeRequest and the id of the record is a3K8E0000000B7S

so I have tried this:

<td>                
    <apex:outputLink value="/apex/SystemChangeRequest/?id=!{Requests.id}">!{Requests.id}</apex:outputLink>                  
</td>

But the link being rendered in the browser is:

https://cs87.salesforce.com/apex/SystemChangeRequest/?id=!%7BRequests.id%7D

so it is giving an 'invalid URL' error.

So what am I missing or doing wrong?

4

You messed up your merge field; it should be {!Requests.Id}. Once you fix that, it should be okay. As an aside, I usually prefer the URLFOR formula, which is future-proof (it constructs the URLs correctly for you). That would look like this:

<apex:outputLink value="{!URLFOR($Page.SystemChangeRequest,null,[id=Requests.Id]}">
    {!Requests.Id}
</apex:outputLink>
  • +1 for URLFOR. – Adrian Larson Jan 4 '16 at 18:15
  • 1
    N.B. merge field enclosed by apex:outputLink could be something more useful like {!Requests.Name} or some other user friendly value – cropredy Jan 4 '16 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.