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 ...


23

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.


20

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>


16

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>";


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 ...


10

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. ...


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 ...


10

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 ...


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 ...


8

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);


8

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></...


7

The Author column is of LookUp Type. Here is the complete list. var ctx = new SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle("Vacation Replacement"); var query = new SP.CamlQuery(); var specifier = "<Where><Eq><FieldRef Name='Author' LookupId='True'/><Value Type='Lookup'><UserID/></Value>&...


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

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


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

I think the problem is with including Query tag in your CAML. Just remove it. Here is a snippet that should work: <Where> <Eq> <FieldRef Name="Title" /> <Value Type="Text">now</Value> </Eq> </Where> <OrderBy> <FieldRef Name="Date_Of_x0020__Posted" Ascending="False" /> </OrderBy>


6

You can use SPServices jQuery Library and CAML query to get data from a SharePoint List and display that retrieved data in Content Editor Web Part where you would write your html table code. To learn more about SPServices refer this: SPServices CodePlex Before writing the below code in Content Editor Web Part make sure you download jquery-1.4.2.min.js from ...


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)


5

Create a calculated column that would calculate if your sort column is not NULL. The formula could look like this =IF(ISBLANK([ColumnName]),0,1) and the result can be 'Yes/No'. Now you can make sorting in your CAML by two columns (the new calculated and later your real column): <OrderBy> <FieldRef Name='MyIsBlankCalculatedColumn' Ascending='...


5

The OOP suggestion solves your context problem but it is kinda like saying: We have a flat tire, lets change cars! Your issue is with the this context you give to your processing function, so lets fix that tire. Instead of passing it the whole truck you only want to pass the payload: with: processItems.bind(request) function getItems(listName,siteUrl){ ...


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