Within my Wrapper Contact's list, I do have Contact records without Accounts. I wanted to have a condition such that the account label is clickable only when there is an Account to that Contact record. Here is what I have implemented, which gets me an error

<apex:column headerValue="Account">
    <apex:outputLink target="_parent" value="{!If(NOT(ISNULL(URLFOR($Action.Account.View, c.actId))), URLFOR($Action.Account.View, c.actId), '#')}" >


Content cannot be displayed: Invalid parameter for function URLFOR

Note: Only few contacts have the AccountIds as null. Where am I doing wrong?

Refernced this link before posting.

  • FYI just use BLANKVALUE. That said, what is the variable type for actId? I don't think String will work, it has to be Id.
    – Adrian Larson
    Mar 28, 2018 at 19:49
  • @AdrianLarson Yes, actId is of variable type Id. Also having BLANKVALUE without the # symbol, gets me the same error message.
    – Arnold Jr.
    Mar 28, 2018 at 19:52

1 Answer 1


Instead of checking whether the URLFOR() function returns null, conditionally render the whole component by wrapping it in an <apex:outputPanel>.

<apex:outputPanel rendered="{! NOT(ISBLANK(c.actId)) }">
    <apex:outputLink value="{! URLFOR($Action.Account.View, c.actId) }" ...>

That way you won't try to render components that don't make sense or cannot be evaluated with a null Id value (it's passing a null Id to URLFOR() that's generating this error, since it gets evaluated inside your IF() even if its result isn't used).

  • Previously I wasn't aware that the URLFOR is being evaluated even without any accountId. That makes real sense for the error.
    – Arnold Jr.
    Mar 28, 2018 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .