1

I have this query that retrieves a List in order to fill a table, but I want to retrieve each documents' user or account according to the AuthorId.

Here is my query that retrieves the documents and I want to adjust it.

public List<Document> documents {set; get;}
.
.
.
documents = [SELECT Description, FolderId,Id, Name,NamespacePrefix, SystemModstamp, Type, Url FROM Document];

and here is the table

<apex:pageBlockTable value="{!documents}" var="d" id="documents_tbl">
   <apex:column >
      <apex:facet name="header">
        <apex:commandLink value="Description"/>
      </apex:facet>
      <apex:outputField value="{!d.Description}"/>
   </apex:column>
   <apex:column >
      <apex:facet name="header">
        <apex:commandLink value="Created Date"/>
      </apex:facet>
      <apex:outputField value="{!d.CreatedDate}"/>
   </apex:column>
   <apex:column >
      <apex:facet name="header">
        <apex:commandLink value="Created By" />
      </apex:facet>
      <apex:outputField value="The users' name"/>
    </apex:column>
</apex:pageBlockTable>
1
  • I don't understand what you want... Do you need also some field from Author? Could you be more specyfic? Commented Feb 20, 2014 at 14:18

1 Answer 1

1

AuthorID specifies the user who is the author, you can just add it to your query. You can also query user fields like any other relationship field:

documents = [SELECT Author.name, Description, FolderId,Id, Name,NamespacePrefix, SystemModstamp, Type, Url FROM Document];

and access it as {!d.Author.name}.

You must log in to answer this question.

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