+ Start a Discussion
amitashtekaramitashtekar 

Problem with URLFOR function

Hi All,

 

I have created a list of a custom object.

One field from the custom object is storing attachment id.

I am saving images within attachments and attachment id is saved to with respective record of custom object.

 

While displaying list of records i want to show the image just aside to record information.

 

I have used the URLFOR function to fetch url of each image attachment

 

but at runtime it is showing me error as

Invalid parameter for function URLFOR

Error is in expression '{!URLFOR($Action.Attachment.Download ,su.AttachmentId)}' in component <apex:page> in page CustomPage
the code for the page is as like
<apex:pageBlockTable value="{!Records}" var="su">
                        <apex:column >
                            <table width="100%" border="0" cellspacing="0" cellpadding="10"
                                style="border-bottom: 1px solid #b7dffe;">
                                <tr>
                                    <td width="130" rowspan="3" align="center">
                                        <apex:image url="{!URLFOR($Action.Attachment.Download, su.AttachmentId)}"
                                                width="60" height="60" id="Image" title="{!su.Info} " />                                        
                                    </td>
                                    </tr></table></apex:column></apex:pageblocktable>
if anyone knows answer for this please help me out.
its very urgent

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

You can use following <apex:image> tag and change the imageid property with your property that will contain the actual image id.

 

<apex:image url="/servlet/servlet.FileDownload?file={!imageid}" width="50" height="50" />

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

You can use following <apex:image> tag and change the imageid property with your property that will contain the actual image id.

 

<apex:image url="/servlet/servlet.FileDownload?file={!imageid}" width="50" height="50" />

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
amitashtekaramitashtekar

Thanks a lot.