I need to add a link from a Case to the Account that is related to the case on a custom visualforce page. When the page is rendered the account id in the url is not generated.

Link in visualforce:

<a href="#" onclick="window.location='/{!Case.Account.Id}'">Employer</a>

Generated HTML:

<a href="#" onclick="window.location='/'">Employer</a>
  • 1
    Just use Case.AccountId... Are you sure the value is not null? Also in general it is better practice to do URLFOR($Action.Account.View, Case.AccountId). – Adrian Larson Jun 8 '15 at 17:30
  • Why cann't you add <a href='../{!Case.Account.Id}">Employer</a>. This should work give a try. – Suresh Jun 8 '15 at 17:30
  • @Suri Why would you traverse up a directory? That relative url would not work in a lot of contexts. – Adrian Larson Jun 8 '15 at 17:31
  • I am using this most of the times and especially when the vf page is embeeded into a standard page. Yes I heared this relative url give trouble some times, but I didnt came across such situation. – Suresh Jun 8 '15 at 17:33
  • @AdrianLarson, the url for action generates an error' Invalid parameter for function URLFOR' – TemporaryFix Jun 8 '15 at 17:35

Try this:

<apex:outputLink value="{!URLFOR($Action.Account.View, Case.AccountId)}">
| improve this answer | |

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.