1

I do get the below error randomly and could not able to figured out what causing this error

Error:

Invalid parameter for function URLFOR Error is in expression '{!URLFOR($Action.Attachment.Download, item.AttachmentID)}' in component

Visualforce page Code:

<apex:column headerValue="Employee">
  <apex:outputLink value="{!URLFOR($Action.Attachment.Download, item.AttachmentID)}" target="_blank">{!item.AttachmentName}</apex:outputLink>
</apex:column>  
1
  • 2
    I am fairly certain that the item.AttachmentID is null or not the attachment object ID. check in your controller and assign non-null id for the URLfor function
    – Rao
    Commented May 9, 2016 at 19:27

1 Answer 1

3

The reason for the error is the parameter where you pass your id is null. So to avoid this error, hide the outputLink completely when the id of the attachment is null

<apex:outputLink value="{!URLFOR($Action.Attachment.Download, item.AttachmentID)}" target="_blank" rendered="{!NOT(ISBLANK(item) && NOT(ISBLANK(item.AttachmentID))}">{!item.AttachmentName}</apex:outputLink>

Hope it helps.

You must log in to answer this question.

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