SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to query and existing sharepoint view. Is this possible? I did not find any tutorial to guide for querying a view.How cant it be done? Kindly tell me is this possible or not and if yes than how?

share|improve this question

migrated from Oct 2 '12 at 19:18

This question came from our site for professional and enthusiast programmers.

Could you please try to rephrase your question? It is difficult to understand what you are trying to accomplish. – Robert Kaucher Oct 2 '12 at 19:29
up vote 2 down vote accepted

I believe this is what you are looking for

Sorry for the powershell snippet, but it will be easy to test and easy to convert for usage in other api's

# Add SharePoint PowerShell Snapin
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
    Add-PSSnapin Microsoft.SharePoint.Powershell

$web = Get-SPWeb "http://url"
$listName = "List Name"
$list = $web.Lists[$listName]

$viewName = "View name" 
$view = $list.Views[$viewName]
## Or get by view id
#$viewId = "A6932332-765A-4776-A1DF-18016DA1D645"
#$view = $list.GetView($viewId)

$query = New-Object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope=""Recursive"""
$query.ViewXml = '<View><Query>' + $view.Query + '</Query></View>'

$items = $list.GetItems($query)

share|improve this answer
This should be the correct answer, you can indeed query a SharePoint List View. – Paul Leigh Dec 3 '13 at 13:51

You cannot query a list view.

A Sharepoint list view - can be create by definitions or by the web UI.

You dont "query" views, you use them to display list information.

You need to be more clearer with what you are asking.

regards, KS

share|improve this answer
This should really be a comment. – Robert Kaucher Oct 2 '12 at 19:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.