It sure looks so from your story, but isn't there a quite easy workaround for this?
<FieldRef Name="ID" />
You don't use ViewFields inside the Where clause in a CAML query. See Query Schema and SPQuery.ViewFields Property
Also, the And around the IsNotNull node is doing nothing. The And needs two child elements to operate correctly.
If you use CAML to get list items (which is the fastest way of retrieving items), it is just enough to get ids of items to be able get the count:
var title = "<Eq><FieldRef Name='Title' /><Value>task 00001</Value></Eq>";
var q = "<Where>" + title + "</Where>";
var lst = web.Lists["Tasks"];
var query = ...
Get Default value for Site Column:
$web= Get-SPWeb http://siteurl
$field = $web.Fields["FieldName"]
$devaultvalue = $field.DefaultValue
Get Default value for List / Library Column
$web= Get-SPWeb http://siteurl
$list = $web.Lists["listname"]
$FieldName = $list.Fields["FieldName"]
You have to use SiteDataQuery as replied by Thomson above.
Here is some sample code
SPWeb web = SPContext.Current.Site.RootWeb;
SPSiteDataQuery query = new SPSiteDataQuery();
//Server template for page library is 850
query.Lists = "<Lists ServerTemplate='850' Hidden='TRUE' />";
query.ViewFields = @"<FieldRef Name='URL' Nullable='True' Type='...
The query in your code is searching for items where field named Hidden has value set to TRUE. My guess is that your list doesn't have field named Hidden.
I will answer your question with some code:
//Always make sure you dispose SPSite and SPWeb objects
using (SPSite site = new SPSite("http://mycoolsite"))
using(SPWeb web = site.OpenWeb())
1) You don't need the ViewAttributes node in your example, as you're targeting a single list.
2) Your pages will be 2000 items long with your current RowLimit attribute
3) You have the throttle mode set to Strict when infact you disable throttling the line after - try it without these settings omitted and logged in as Admin first.
4) Have you tried a ...
This is a well known and very difficult to solve problem, especially when it comes to large volumes of data. Even not touching SharePoint, you might have noticed that many systems (Google is an obvious example) return only approximate number of filtered elements.
Basically the only thing you can do is to perform the same query but exclude permissions and ...
How about creating the SPQuery object using the constructor where you can pass the appropriate SPView.
You could then add a query to include the appropriate items, something like:-
var query = new SPQuery(spView);
query.Query = String.Format("<Where><Eq><...
Can't comment due to low rep so posting as an answer, purists forgive.
Breaking a 500 element In into several nested Or tags does not work, to my despair. The limit is 500 elements hard apparently.
I have tried breaking using a limit of 500 elements, 400, 300, 200, 100, and the SPServices query failed, returning: 500 Internal Server Error with the ...
AFAIK it's not documented anywhere which fields should be included to be able to do an Update after querying with ViewFieldOnly set to true, but according to SPQuery.ViewFieldsOnly and Updating an SPListItem it's amongst other ID, UniqueID, object type, ...
BUT my recommendation is definitely don't even try, just set ViewFieldsOnly to false, then you're ...
You can not have more than 2 statements in every <And> / <Or> tag. Also you seem to be missing an <Eq> (or whatever you need) around your first <FieldRef> tag.
So instead do this
myquery.Query = "
<FieldRef Name='Company'/><Value Type='Text'>" + ...
What is important here is to get the datetime format right. If you use it programatically you could either use this
string sendDate = sendDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
..or you could use the SPUtility.CreateISO8601DateTimeFromSystemDateTime method to achieve the same. Beyond this you could also consider using "relative" expressions based on Today ...
There is no memory leak in your code for SPWeb. The SPWeb object you get from SPContext.Current.Site.OpenWeb(webUrl) should be disposed (like you already did).
There is are other performance improvements I can suggest in your code:
1) Use list = web.GetList(lstUrl) instead of list = web.Lists[listName] ;
2) Use list.GetItems([SPQuery]) instead of list....
You're disposing an instance of SPWeb got through using SPContext. This probably will result in unpredictable behaviour as something else is expecting to dispose of the Site object you've got it from.
Rather, use new SPSite(SPContext.Current.Site.Url) and wrap that in a using tag like you've done there.
EDIT: Yeah, you're using OpenWeb() which does indeed ...
You get that error when the fields used in CAML query fields or viewfields are not present in that list. CAML uses the internal name and not the display name. Verify that the ticketid is the internal name of that field and not display name. Go to list settings and click on the field ticketid and observe the url for the param value 'field'. This should match ...
As Hugh said, in the getSelectedList function you have the first error.
SPListCollection myLists = myWeb.Lists;
foreach (SPList myList in myLists)
rList = myList;
This will dispose the myWeb istance after the using block. The suggested way from ...
Unfortunately, SharePoint paging works a bit differently than LIMIT and OFFSET in SQL. To get paginated items you have to provide ID of the first item for the page you want and then set RowLimit, and if you have sorting defined for the list, you also have to provide sorting columns names and values of those columns for the first item on your page.
You can ...
My understanding of how the List View Threshold works is limited, however, I suspect the reason your CAML query is failing is because it is filtering on the non-indexed field, and the RowLimit is applied "after".
I think that indexing the CheckoutUser field would solve your problem, however it sounds like you have a lot of sites.
Allow me to suggest an ...
Your code looks like Server Object Model. Based on my experience on using CAML queries, I can suggest you to get rid of <Query> tags. So update your query as below
Query = "<Where>" +
"<FieldRef Name='ows_PostID' LookupId='TRUE'/>" +
"<Value Type='Lookup'>" + ...
Why do you create SPQuery based on view? You're defining explicitely the fields to return and the query. So can you use parameterless SPQuery constructor? Maybe there's some conflicts betweeb view settings and your new query conditions.
If your WCF is located under '_layouts' folder and configured correctly you have access to the SharePoint object model as in web parts, application pages, etc. So you can use list.GetItems(spQuery) method to filter items.
You can read more about WCF services and SharePoint here. How to configure your service you can find in this post.
I really don't see a way you can do this...not with a CrossListQuery anyway. If you were doing this against a single list (i.e. SPList.GetItems(SPQuery) then you could add:
<Eq><FieldRef Name='FileDirRef'/><Value Type='Text'>"ListName"</Value></Eq>
and that would pull back only the top level folders, as the folders under that ...
Create your query with the U2U Caml Query builder:
(This works with 2010 as well)
Ideally the following query should work:
<FieldRef Name="SendDate" />
<Value IncludeTimeValue="TRUE" Type="DateTime"&...
While SPQuery is part of the Microsoft.SharePoint.dll which can be used on the Server Side in Farm or Sandbox solutions through Custom C#/.NET code.
Use SPGridView instead of ASP:GridView...
Here is a nice article: How to use the SPGridView filter together with a SPDataSource
I also noticed in every example in CAML before <Query> they are using <View>, but I don't know if this is really the problem... can you please try that as well
Hope this ...