SPQuery represents a query in a list view.
6
votes
2answers
2k views
Can I order by Content Type in a CAML query?
Is it possible to order by content type in a CAML query?
I seem to always get the same result no matter what I do with the Order by. Ordering by ID instead works perfectly.
query.Query = @"
...
5
votes
1answer
892 views
SPList.GetItems query returning an invalid SPListItemCollection. What am I doing wrong?
I'm trying to query an SPList object using a CAML query (see code below).
SPQuery queryGetExistingTargetTask = new SPQuery();
queryGetExistingTargetTask.Query = ...
5
votes
2answers
717 views
Problem with CAML SPQuery ItemChildCount result
I know that this query works fine
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='ItemChildCount' Ascending='FALSE' /></OrderBy>";
But my ...
4
votes
1answer
3k views
CAML query with more than multiple AND/OR generates SPException “One or more field types are not installed properly. Go to the list settings page to delete these fields.”
I need to build a CAML query at runtime based on user input. The CAML query could be as simple as
<Where>
<Eq>
<FieldRef Name="Status" />
<Value ...
4
votes
2answers
199 views
SPQuery returning different before and after using RunWithElevatedPrivileges method
I am having a huge problem here.
I am executing a query looking for a SPListItem, when I execute this query with user identity it works well, retuning the fields "Author" and "Editor" that I need.
...
3
votes
1answer
2k views
How do I query a list using CAML and SPQuery?
I have a SPList but I don't need to go through everything in that list. I need to establish a CAML query so I can limit the list items. Then, go thru each item from the query result and do something. ...
3
votes
1answer
688 views
Is it possible to return only the count of the query?
Is there any way to return only the count of the rows from a Sharepoint query? I would like to get only the count of the result returned by sharepoint query.
3
votes
2answers
626 views
Use SPQuery.RowLimit also on large lists with small query results?
I frequently read one should use RowLimit on SPQuerys on a large list, especially with more than 2000 items.
Best Practices: Common Coding Issues When Using the SharePoint Object Model:
An ...
3
votes
1answer
140 views
Fetching from large lists while throttling is enabled
Here's the situation:
I have a heavily customized web application built on top of MOSS 2007
We're in the process of upgrading the application to SharePoint 2010
QA has identified that a page which ...
2
votes
1answer
238 views
Why do I sometimes have to use different SPQuery tags?
Every SPQuery's query should have
<View><Query> query... </Query></View>
tags?
Sometimes I have to put without those tags to get it work and some times I have to put it ...
2
votes
2answers
192 views
Get SPQuery TotalItems from query
I want to get the total number of items that match my Query, BUT also limit the results.
So say I have 100 items in the list.
50 of the 100 items in the list match my query.
I want to only get 10 ...
2
votes
3answers
898 views
CAML Query Maximum Size
I am running a sharepoint caml query where I want to check that a field on an item is equal to one of many values. I do this dynamically and may wish to check against many hundreds of values.
I found ...
2
votes
2answers
244 views
SPQuery works on libraries under the list view threshold, but not over
So I am building a webpart which enumerates all doclibs in the current web, grabbing all checked out files and listing them in a table, allowing a user to apply some required metadata and check in ...
2
votes
1answer
1k views
CAML 'Endswith' equivalent?
I have to pull the data from the custom list by using a CAML query.
I would like to use the "Endswith" option in the CAML query however it seems to be unsupported in sharepoint 2007.
What would be ...
2
votes
2answers
727 views
CAML OrderBy and managed metadata
I have something like this:
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef name=\"MyTerm\" /></OrderBy>";
myList.GetItems(query);
I can sort on normal fields, ...
2
votes
1answer
74 views
SharePoint 2013 list items paging
I'm trying to make a webpart with list items paging. I followed this link http://www.directsharepoint.com/2011/03/step-by-step-guide-to-implement-paging.html
and on SharePoint 2010 server it works ...
2
votes
1answer
146 views
Caml Query - skip X first results
Let's assume I have list with 100 items. Is it possible to write CAML query to get 5 items, but skip 10 items from the beggining? Something like LIMIT and OFFSET in SQL?
2
votes
2answers
136 views
QueryThrottleMode in non-query operations?
I have a big List which I want to empty. Therefore I create a template from that list, delete the list and create a new list from the template I just saved before.
I know there are other ...
2
votes
1answer
702 views
Search Optimization on SPListItemCollection
I have an SPListItemCollection (Thread Discussion Collection) that consists of almost 20,000 items. Each SPListItem (Thread Discussion) on the SPListItemCollection contains a sub SPListItem(Thread ...
2
votes
2answers
1k views
Maximum lookup columns - the magic number 13
So I did create on an SPWeb 20 custom lists and then a tasks list.
For each of those 20 lists I've created 20 site lookup columns. I then created 20 Content Types based on Task content type. Then I've ...
2
votes
0answers
33 views
Mysterious DBCS (Double-Byte-Characters), i.e Kanji from SiteData query
Records returned from SPWeb.GetSiteData have some fields encoded in DBCS (Kanji characters). What could be causing this?
2
votes
0answers
1k views
How to get the particular columns from a SharePoint list view
I am using SPQuery to fetch data (particular columns from the list based on viewID) from SharePoint list. Here is the code for fetching the data:
SPQuery sQuery = new SPQuery();
currentlistview = ...
1
vote
3answers
441 views
is this causing memory leaks?
I have a couple of utility functions that help with querying lists and wanted to see if they I wrote them would cause either memory leaks or cause the client code to try to access already disposed ...
1
vote
1answer
325 views
SPQuery.ViewFieldsOnly in WSS3?
In SharePoint 2010 SPQuery has the ViewFieldsOnly property that apparently optimises the query by only returning the data you specifically ask for.
Unfortunately the 2007 version of SPQuery doesn't ...
1
vote
1answer
526 views
Getting User details from field “AssignedTo” in a custom List
I have a Custom List, which have different fields, when I click on any user in field "assignedTo" it navigates me to another window and I can see user's Account, Name, email etc.
I am able to get all ...
1
vote
2answers
3k views
Create CAML SPQuery to order by ItemChildCount in descending order
How do I create a CAML query to display all items on the list order by ItemChildCount?
Somewhat like this:
Select *
from table
order by itemChildCount descending
1
vote
2answers
913 views
How to get the last x number of splistitems changed for a SPWeb
I'm trying to pull back the last x number of list items in all non-hidden lists for a given web.
My original code would go through all lists and run the following code:
SPQuery query = new ...
1
vote
2answers
442 views
Simple SPQuery throws error
I am trying to pull populate a lookup field using a lookup value without the lookup ID. I am getting the error: "One or more field types are not installed properly. Go to the list settings page to ...
1
vote
2answers
913 views
date ranges in CAML queries
I have a list with a datetime filed.
I want selected items from this with date rang.
I use this code
<Where>
<And>
<Geq>
<FieldRef Name='SendDate' /> <Value ...
1
vote
1answer
207 views
Is it possible to use spquery in WCF for sharepoint
I created custom wcf that retrieve items from the list. Is it possible to use spquery within the wcf to filter the list items
1
vote
1answer
443 views
How do I select only top level folders using CrossListQueryCache?
I want to select the list of folders (without subfolders, not recursive) of a Document library using CrossListQueryCache.
Everything is working fine except that i am receiving ALL the folders and ...
1
vote
1answer
71 views
SPQuery on null lookupfield
I have a contact list with a company lookup field and I need to retrieve those without any company associated
so I was thinking can I put it like this:
<Query>
<OrderBy>
...
1
vote
2answers
223 views
SPQuery always returns values
I am trying to check a list for related values but for some reason every item in the list is returned each time. I have seen this issue before and for me its always meant a bad CAML string but I have ...
1
vote
2answers
331 views
GetDataTable from SPListItemCollection
My question is regarding the use of DataTable vs ListItemCollection. Basically I have a small solution, where I have to loop through the items in the list to verify if the items already exists or not.
...
1
vote
3answers
940 views
How do I programmatically alter sort and include columns in the “All Items” view?
How to programatically alter existing view "allitems.aspx" aka "All Items" to do an OrderBy (sort by first name and group by department) and only display first, last, m, date of birth, date of hire, ...
1
vote
0answers
115 views
SPSiteDataQuery without subfolder items?
I'm trying to use the SPSiteDataQuery to return the contents of several lists across a site collection. The problem I'm having, though, is that while there are only a few documents at the root level ...
1
vote
1answer
158 views
SPQuery - join two tables and count each
I have two tables with a 1-M connection and have not been able to correctly convert the following SQL into a caml/spQuery
I want every value in table A once no matter what & table B divided into ...
1
vote
0answers
114 views
SPQuery on ECT very slow
I am creating a custom web part which is supposed to return results from an External Content Type(ECT) List which contains almost 40,000 records. There are multiple ways the items can be searched and ...
1
vote
0answers
94 views
How to display fields of parent list and foreign list using spquery
I have created parent list that lookup to another list . Both the list having one identical column label but different values(column name: displayorder).I projected the displayoreder column from ...
1
vote
0answers
984 views
ProjectedFields working in SPQuery but not in the View
I've three lists: Competitions, Works and WorksVotes, linked to each other through Lookup fields.
WorksVotes list has Lookup field to Works list, and Works list has Lookup field to Competitions list.
...
1
vote
0answers
282 views
Is there a simple way to add paging to ListViewByQuery ?
I'm working with a ListViewQuery component on a webpart and I need to add paging control to it.
Is there a simple way to achieve that ?
I saw somewhere than just setting the RowLimit property of ...
1
vote
3answers
1k views
Sharepoint 2010 SPQuery to join two custom lists
I have two custom lists.
list 1 having following columns:
ID (consider as PK)
title
list 2 having following columns
NID (lookup column)
title
I'm using spquery.joins like below
<Joins>
...
0
votes
4answers
901 views
Detected use of SPRequest for previously closed SPWeb object after SPQuery
this code run yesterday very well and today I've been trying to solve this error for hour now :
Please close SPWeb objects when you are done with all objects obtained from them, but not before
I ...
0
votes
2answers
1k views
How can use API to get all Publishing pages in the site collection using a specific Content Type?
I need to use API to return all Publishing pages using a specific content type in a publishing site. this includes querying all sites in the site collection. Can I do that with SPQuery?
I am using ...
0
votes
1answer
343 views
SPDataSource for asp gridView returns nothing?
I'm binding my SPDataSource to an ASP:DataGrid but it returns empty gridview not filled.
Here's my aspx file
<SharePoint:SPDataSource runat="server" ID="SPTypes" DataSourceMode="ListItem" ...
0
votes
1answer
851 views
Adding IsNotNull and ViewFields in CAML Query
Trying to add IsNotNull parameter and ViewFields paramter but throwing an error. Am I inserting incorrectly or missing something to make sure this executes correctly? Seems like View is bring back all ...
0
votes
3answers
390 views
What is the difference between CamlQuery and SPQuery
Maybe a simple question, when to use CamlQuery and when to use SPQuery ?
I think that SPQuery is used inside a WebPart running on the SharePoint server, and that CamlQuery is part of the Client ...
0
votes
2answers
2k views
SPQuery for Selecting/Excluding Hidden columns from a SPlist
I am trying to take a DataTable containing ID and other columns which are not hidden.
I am doing this for a generic list which contains any number/type of columns. so I don't know the field names ...
0
votes
2answers
1k views
Error while trying to query the custom list sharepoint 2010
I am trying to query a custom list and getting the following error:
At,
SPListItemCollection OsplistitemCollection = Olist.GetItems(OqueryResponse);
below is my code
string TicketID = "123";
...
0
votes
1answer
447 views
SPQuery works on ListViewByQuery but not with GetItems
In one of my webparts, I have a ListViewByQuery displaying some elements (or all) of a specified list. The SPQuery is built dynamically depending on the search fields.
Here is how I build the ...



