Questions tagged [spquery]

SPQuery represents a query in a SharePoint list view

SPQuery represents a query in a SharePoint list view. Collaborative Application Markup Language (CAML) can be used to define the query.

Example:

SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb
SPList oList = oWebsiteRoot.Lists["Tasks"];

SPQuery oQuery = new SPQuery();
oQuery.Query = "<Where><Eq><FieldRef Name='Status'/>" + 
               "<Value Type='Text'>Completed</Value></Eq></Where>";

SPListItemCollection collListItems = oList.GetItems(oQuery);

foreach (SPListItem oListItem in collListItems)
{
    Response.Write(SPEncode.HtmlEncode(oListItem["Title"].ToString()) + 
        "<BR>");
}

MSDN - SPQuery

39 questions
0
votes
3 answers

SPQuery sorting issue

I have this SPListItem.Folder in sharepoint that contains a property named "Asset ID". I have this data in my list Asset ID | Name | Asset Type 1 | GamesFolder | Games 2 | AppsFolder | softwares 3 | …
Carls Jr.
  • 3,088
  • 7
  • 37
  • 57
0
votes
1 answer

filter items by Site name and List Name using SPSiteDataQuery

I am listing files from multiple folders using the below code: SPSiteDataQuery q = new SPSiteDataQuery(); q.Lists = ""; q.Query = "
ehabzag
  • 99
  • 2
  • 11
0
votes
1 answer

Data returned if GetItems if query did not match

This is really a simple question. What does GetItems method return if SPQueryobject did not find any match? if i call the update method, if it did find anything. Will it add it? I'm at the point of investigating a bug and I still don't have a…
ivatanako
  • 13
  • 3
0
votes
1 answer

Sharepoint SPQuery problem

I'm trying to use GetItems() method on a SPList and I pass SPQuery to it. The problem is, it return all the items from my SPList instead of just the filtered ones. My query looks like this:
matt99
  • 869
  • 2
  • 8
  • 19
0
votes
0 answers

defining custom function for crown area sum in ForestTools R package?

I'm using ForestTools package to segment trees from the chm raster, and calculating crown area. The package works quite fine, but I'm unable to calculate the sum of all crown areas within a specific grid of 30x30m. Is there a way to define the…
james
  • 15
  • 3
0
votes
2 answers

SPQuery not returning expected results

I am trying to search for an item in a SharePoint list using SPQuery, but even though the file is there, the result is null. The code is the following: var query = new SPQuery(); query.Query = "
Mimi
  • 41
  • 2
  • 7
0
votes
1 answer

Collection was of a fixed size Error when Adding New User to SharePoint object

I encountered the following error when adding a user to a SharePoint folder object: Exception calling "Add" with "1" argument(s): "Collection was of a fixed size." At D:\User\Script1.ps1:114 char:17 …
gymcode
  • 4,431
  • 15
  • 72
  • 128
0
votes
1 answer

SharePoint: Validating SPQuery

I am writing an internal API for my company which allows users to pass in SharePoint CAML query. In side my function I take to user's query, and add some additional elements to it and then use the final query to retrieve required data from…
Moon
  • 33,439
  • 20
  • 81
  • 132
0
votes
1 answer

search sharepoint list column item having same value

Suppose i have a sharepoint list. Please find below details Listname="NameData" Name ModifiedDate Place keshav 19/12/2015 A madhav 19/11/2015 B keshav 19/10/2015 C madhav 19/10/2015 D Ram 19/10/2015…
0
votes
1 answer

how to get fields list of view fields from SPSiteItemCollection

I want to get fields list of SPSiteItemCollection that limited by SPQuery view fields. for example I limited the view field which CAML query like this: spQuery.ViewFields=""; and I executed query with this code and…
Mehdi
  • 1,731
  • 1
  • 18
  • 33
0
votes
1 answer

Take name and count number of sibling classes in generated ontology using Java

I first generated the ontology. It was successful. Then, I want to take sibling classes name for each class and count number of sibling classes of each class in the generated ontology.As a example, Main super class- A Two sub classes of A -…
Emalka
  • 381
  • 2
  • 4
  • 16
0
votes
1 answer

ViewField order in SPQuery affecting performance

I've encountered a strange issue when writing an SPQuery and specifying ViewFields. I have eight fields that I need. Five of them are indexed. My issue is that depending on the order in which I specify these ViewFields the performance of my query is…
Nick
  • 1
0
votes
1 answer

How can I write a SPQuery to filter items based on a LinkFieldValue?

I need to select a single value from a SharePoint list based on a field value. The type of the field is LinkFieldValue. How should I write the CAML query? When I select the items with an empty query, I receive all the items in the list as…
skolima
  • 31,963
  • 27
  • 115
  • 151
0
votes
1 answer

Can I retrieve additional fields for a SPListItem from SPQuery which had ViewFields set?

I am retrieving SPListItems from SPList with a SPQuery that has ViewFields set. I am using ViewFields to improve performance. However, for some items, I need additional data. I know I can just retrieve the single item again with a new query.…
skolima
  • 31,963
  • 27
  • 115
  • 151
0
votes
2 answers

SharePoint: Efficient way to retrieve all list items

I am retrieving all items from list containing around 4000 items. But it seems to take longer time to fetch all items which is ~15 to ~22 seconds. Is there any best way to fetch all items from list in negligible time? Following is the code i am…
Ashish
  • 246
  • 1
  • 2
  • 12