+ Start a Discussion
Neha RNeha R 

How to query id for article attachments

Hi,
We have a custom Visualforce page to view articles, there is an output link to download the attachment on that page (<apex:outputLink value="/servlet/fileField?entityId={!articleId}&field=Attachment__Body__s"/>)
The Customer Community Users are getting an error when using the link to download the files that cannot be rendered by the browser e.g. excel, pdfs etc, text file attachments however are being opened in the new window. The users with Salesforce license are able to download all attachment types.

Error Message-
Unable to Access Page 
The value of the "field" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.

Question-
My Question is, is there a way to query for the uploaded attachment file id using article id in the controller and pass it to the VF page so i can build my output link directly, something like this -
<apex:outputLink value="/servlet/fileField?id=<Article's Uploaded File ID"/>
I am unable to find how to query for the attachment file id