Hot answers tagged

39

CAML Designer The one that works is this URL: http://camldesigner.blob.core.windows.net/offlinepackage/CamlDesigner2013.zip The link comes from Karine Bosch's Blog. CAML Designer is the successor of CAML Builder, and from experience I can tell you this tool is much better and accurate. I've tried the both. Edit: Looks like the CAML Designer now is a ...


29

It sure looks so from your story, but isn't there a quite easy workaround for this? <Where> <Or> <In> <FieldRef Name="ID" /> <Values> <Value Type="Number">1</Value> <Value Type="Number">2</Value> . . . <Value ...


28

Try to use this caml: <Where> <Eq> <FieldRef Name="Author" LookupId="True" /> <Value Type="User">123</Value> </Eq> </Where> this also might work, but first is preferable: <Where> <Eq> <FieldRef Name="Author" LookupId="True" /> <Value Type="Lookup">123</Value> &...


21

Default lookup query uses the value instead of lookup Id The typical query looks like <Query> <Where> <Eq> <FieldRef Name='RefCountry' /> <Value Type='Lookup'>India</Value> </Eq> </Where> </Query> To query by ID you have o setup LookupId='TRUE' attribute ...


20

<OrderBy> <FieldRef Name='Region' Ascending='True' /> <FieldRef Name='Location' Ascending='True' /> </OrderBy> Should be the correct syntax for the order by clause.


18

Try this: <OrderBy> <FieldRef Name="ID" Ascending="TRUE"/> </OrderBy> <Where> <And> <Eq> <FieldRef Name="HomeType"/><Value Type="Choice">Condo</Value> </Eq> <Eq> <FieldRef Name="LastName"/><Value Type="Text">Doe</Value> </Eq> </And> </Where>


15

You can use a SPSiteDataQuery to query multiple lists (within your site structure) and filter based on Content Type. Something like this: <Where> <Eq> <FieldRef Name='ContentType'/> <Value Type='Computed'>YourCustomContentTypeName</Value> </Eq> </Where> Tip: Download CAML Designer which will assist you ...


13

Modify var camlQueryString = "<Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query>"; to var camlQueryString = "<View><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Number'>{ADD LIST ITEM ID HERE}</Value></Eq></Where></Query></View>";


12

It is more a caml question than an SPServices question. Often one uses or and and operators to combine multiple values, which, like @rjcp3 said, can be messy. There is another operator, less known, IN operator to choose a range of values (see the xml example below). To simplify the creation of CAML queries in javascript, I'd recommend SharePoint ...


11

First of all you should just rule out the use of SQL. You should not use SQL directly against SharePoint content databases. If you ever do modifications directly using SQL that SharePoint Farm becomes unsupported for ever. Even just doing reads makes your SharePoint Farm unsupported as long as they are occuring and may cause any kind of problems as ...


10

Try ContentTypeId in the CAMLQuery: <BeginsWith> <FieldRef Name='ContentTypeId' /> <Value Type='ContentTypeId'>YourContentTypeIdHere</Value> </BeginsWith>


10

As far as I know it is not supported to apply $filter or $select expression for the endpoint: http://<sitecollection>/<site>/_api/web/lists(listid)/getItems(query) To summarize: CAML and OData query could not be combined. From another hand, since expanding of User Fields is not supported in CSOM/REST i would suggest to construct your query ...


9

You have several options for your type attribute in your value element. You can use Boolean, Choice, Currency, DateTime, Guid, Integer, Lookup, Note, Text, User. These type attributes are required, and can't be omitted. As regards to performance, CAML itself is faster than say LINQ, which at first need to be converted to CAML and then query the database. ...


9

CAML queries are NOT vulnerable to SQL injection. I don't think you'll find any direct reference or proof. Consider that the conversion from CAML to SQL all happens between the data layer and the SharePoint API. You can't control how SharePoint generates the SQL for a given CAML statement and therefore you don't have to worry about SQL injection. That's ...


9

Considered that Team and Department columns are text column. "<Query><Where>"+ "<And>"+ "<Or>"+ "<Or>"+ "<Eq><FieldRef Name='Team' /><Value Type='Text'>A</Value></Eq>"+ "<Eq><FieldRef Name='Team' /><Value ...


7

<Where> <And> <Eq><FieldRef Name="IssueLOB" LookupId="TRUE" /><Value Type="Lookup">1</Value></Eq> <And> <Eq><FieldRef Name="IssueBucket" LookupId="TRUE" /><Value Type="Lookup">1</Value></Eq> <Eq><FieldRef Name="IssueStatus" LookupId="TRUE" /><Value Type="Lookup">1&...


7

Yes you can, but you will have to load the list item collection seperately like below and call executequery once. clientContext.load(collListItem); clientContext.load(collListItem1);


7

Replace <Geq> <FieldRef Name='vpux'/> <Value Type='Text'>" + dateNow + "</Value> </Geq> with <Geq> <FieldRef Name='vpux'/> <Value IncludeTimeValue='TRUE' Type='DateTime'><Now /></Value> </Geq> You can use <Today /> as well. IncludeTimeValue is, obviously, for ...


7

var context = new SP.ClientContext.get_current(); var list = context.get_web().get_lists().getByTitle("ListName"); var cQuery = new SP.CamlQuery(); var camlXML = "<View><Query><Where><Eq><FieldRef Name='Author' LookupId='True'/><Value Type='Lookup'>" + _spPageContextInfo.userId + "</Value></Eq></...


6

To achieve this, You can use ListItemCollectionPosition property. It is used together with the RowLimit property to define paging in a query. For your reference, see the sample code available this link http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.listitemcollectionposition.aspx I hope this will resolve your problem.


6

camlQuery.set_viewXml('<View Scope="Recursive"><Query></Query></View>'); camlQuery.set_folderServerRelativeUrl(folderPath);


6

Yes, it's your nesting. Try this: <Where> <And> <Eq><FieldRef Name="Status" /><Value Type="Text">A</Value></Eq> <And> <Eq><FieldRef Name="Region" /><Value Type="Text">B</Value></Eq> <And> <Eq><FieldRef Name="BagVal" /><Value Type="...


6

Try this: splist li = web.lists["Films"]; spquery q = new spquery(); q.Query=""; //Enter a caml query here if you would like to restrict your results... q.ViewFields = string.Concat( "<FieldRef Name='FilmID' />", "<FieldRef Name='FilmName' />", ...


6

The trick is to set the CAMLQueryOptions so that you get all the items regardless of what folder they are in. It's sort of like the "folderless" option in a view's settings. CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll' /></QueryOptions>"; The GetListItems documentation on MSDN is a little light on these options. ...


6

Query in your case is a string, which means that you are using the SPList.GetItems(String[]) overload. That method accept a list of fields to load, not a query. You should be using one of the overloads that accepts an actual SPQuery object.


6

SP.CamlQuery does not have a property RowLimit , you have to set in the caml markup: camlQuery.set_viewXml("<View><Query> <OrderBy> <FieldRef Name='ID' Ascending='False' /> </OrderBy> </Query> <RowLimit>5</RowLimit> </View>");


6

"<Query><Where>"+ "<Or>"+ "<Or>"+ "<Or>"+ "<Eq><FieldRef Name='UserName' /><Value Type='User'>" + User.Name + "</Value></Eq>"+ "<Contains><FieldRef Name ='OtherUsers'/>&...


5

You should use the Internal Name of the column, so its probably: Link_x0020_to_x0020_Page Easy way to check the internal name is from the url when you edit the column, and check the "Field=" part of the URL: FldEdit.aspx?List=%7B6045095F%2DC5AF%2D47D5%2DA481%2D27665B46E343%7D&Field=Link%5Fx0020%5Fto%5Fx0020%5FPage Replace %5F with underscore, or just ...


5

One oddity about the JSOM is that you need to wrap the CAML query in a <View> tag. var proproductIDVal = "TR543A1Z"; var queryXml = "<View><Query><Where><Eq><FieldRef Name = 'ProjectID'/><Value Type='Text'>" + productIDVal + "</Value></Eq></Where></Query></View>"; var query = new SP....


5

U2U CAML Query Builder is now available again and updated for SharePoint 2013: http://www.u2u.be/Software You can also check out these alternatives: Stramit Caml Viewer SharePoint CAML Query Helper Caml Designer for SP 2010 and SP 2013 CAML Generator (taken from my post on Stackoverflow)


Only top voted, non community-wiki answers of a minimum length are eligible