Wednesday, June 20, 2012

No Author (Created By) Field in SPList.getItems(SPQuery).

Hi,

I assume that you all know that all the list items can be retrieved from SharePoint List using

SPList.getItems(SPQuery)

And returns all the items based on user permission and Filter that were specified in query. The columns that it return by default (For a document library) are

FileLeafRef
Title
ID
ContentType
Created
Modified
_CopySource
_CheckinComment
LinkFileNameNoMenu
LinkFilename
DocIcon
FileSizeDisplay
ItemChildCount
FolderChildCount
Edit
_UIVersionString
ParentVersionString
ParentLeafName
CheckoutUser
Editor

And Author.

The reason why i mentioned Author separately is because GetItems() method return Author Filed only for SiteCollection Admins and application pool admins. 
 
Regual user like site administrator, modifiers, visitors will not get that column.
 
If you are trying to get datatable from GetItems() method and use a custom column that shows Author (created By) column make sure to user elevated privileges based on your need.