0

I am trying to show the PDF file of a link but when I try to pass the document Id I get the following error Error: Compile Error: Initial term of field expression must be a concrete SObject: List

documents = [SELECT Id, Name
                                    from Document
                                    WHERE Document.folderid = '00lG0000001bBXb'
                                    ORDER BY LastViewedDate DESC Limit 5];

public string pdfView {get;set}
         for (documents doc : documents){
          pdfView = '/servlet/servlet.FileDownload?file='+ doc.Id+'&headerHeight=null&footerHeight=null#toolbar=1&navpanes=0&zoom=90' ;
          }

Visualforce page

<h2>DOCUMENTS</h2>
                <ul>
                    <apex:repeat value="{!documents}" var="document" id="recentDocsRepeat">
                        <li>
                            <apex:outputLink value="/{!pdfView}" id="docListItem">{!document.Name}</apex:outputLink>
                        </li>
                    </apex:repeat>
                </ul>
0

I got it fixed I was using documents instead of the type of Documents

for (Document doc : documents){
              pdfView = '/servlet/servlet.FileDownload?file='+ doc.Id+'&headerHeight=null&footerHeight=null#toolbar=1&navpanes=0&zoom=90' ;
              }
|improve this answer|||||
  • Can you please add some explanation about why that fixed the issue? – Adrian Larson Sep 8 '16 at 21:47
  • sure @AdrianLarson I just added – Metawaa Sep 8 '16 at 22:07

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.