Hot answers tagged

32

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


27

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


16

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


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


12

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

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>


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


7

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

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


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

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

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


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


5

<Or> should be the outer one and <And> should be inside. Try below: <Where> <Or> <Eq><FieldRef Name='Name' /><Value Type='Text'>JDoe123</Value></Eq> <And> <Eq> <FieldRef Name='LastName' /> <Value Type='...


5

Your caml query should have <Value Type="Lookup">9</Value> instead of <Value Type="Integer">9</Value>


5

In SharePoint Online, your only choice is to use REST. CSOM will not work. You call the REST endpoint and it will return a batch of 100 or 200 items, and if more exist, will return a paged link to access the next batch of data. I've used this technique in the past to update 100k+ items in a document library with success (in PowerShell), CSOM would not work....


5

You'll want to use the Greater than or Equal operator (Geq) and then use the Today element for relative comparison: <Where> <And> <Eq> <FieldRef Name="Status"/> <Value Type="Choice">NEW</Value> </Eq> <Geq> <FieldRef Name="Created"/> <Value Type="...


4

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


4

I think your definition for the join is wrong. I think it should be: <Join Type='LEFT' ListAlias='PartnerLookup'> <Eq> <FieldRef Name='Partner' RefType='ID' /> <FieldRef List='PartnerLookup' Name='ID' /> </Eq> </Join>


4

I think that this code: <Eq> <FieldRef Name = "HomeType"><Value Type="Choice">Condo</FieldRef> </Eq> must be like that: <Eq> <FieldRef Name = "HomeType" /><Value Type="Choice">Condo</Value> </Eq>


4

Add after </Where> <QueryOptions> <ViewAttributes Scope="RecursiveAll" /> </QueryOptions> Reference: Need a CAML query to "show all items without folders" in sharepoint list view.


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