Hot answers tagged

27

CAML Designer The one that works is this URL: http://sharepoint.biwug.be/CamlDesigner/CamlDesigner.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 subscription application, ...


14

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


14

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


12

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


11

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


10

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


10

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


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


8

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


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


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


6

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


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

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.


5

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.


5

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


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


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


5

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


5

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


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


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


4

Paging in SPQuery is implemented through the class SPListItemCollectionPosition. The SPListItemCollection returned by SPQuery.GetItems contains a ListItemCollectionPosition property which is null if no more pages and otherwise can be used assigned to the corresponding property in SPQuery before a new call to GetItems. (Sample at the link above)


4

Remove <Query> and </Query> from your string


4

Frank, I don't think it's possible to do what you want. If search returned all of the versions, we'd have a real mess on our hands. You're right that the Author (Created By) is the original creator and the Editor (Modified By) is the last person who made an update. To add to the complexity, those roles may have only made changes to metadata and not the ...


4

To solve this issue, just remove the <Query> and </Query> tags from the CAML query it should all work.


4

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


4

When using you want to use the Offset=""(or according to the comments on MSDN attribute should be OffsetDays="") on the Element <View> <Query> <Where> <Eq> <FieldRef Name="EventDate" /> <Value Type="DateTime"><Today OffsetDays="+1"/></Value> ...


4

You can use <Today /> tag to get current date , additionally if you add IncludeTimeValue='TRUE', it will get you current time. Try this: <Where> <Gt> <FieldRef Name='YourColumnName' /> <Value IncludeTimeValue='TRUE' Type='DateTime'><Today /></Value> </Gt> </Where>


4

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 = " <Where> <And> <Eq> <FieldRef Name='Company'/><Value Type='Text'>" + ...



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