A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Hot answers tagged

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


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

AFAIK there is no way to query SharePoint using SQL syntax. You have the following options: Use CAML Use the REST services (_vti_bin/ListData.svc) Use the SharePoint web services Use Search (Search has a SQL like syntax) Some custom stuff that "exports" your data (using method 1-4) to a queryable SQL db I think your best option are #2 - the REST/OData ...


8

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: //some query var title = "<Eq><FieldRef Name='Title' /><Value>task 00001</Value></Eq>"; var q = "<Where>" + title + "</Where>"; var lst = web.Lists["Tasks"]; var query = ...


7

Use below code to get User name: new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupValue; For User ID: new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupId;


6

You can use PageQueryString and/or PageFieldValue in the CQWP. Here is an exmaple


6

Try isActive=1 this means it equals true. isActive:1 is a contains query.


6

Use two quotes. That is for 'aaa'aaa' use 'aaa''aaa'


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

Well I've found a solution, not very friendly but works, is based on this article So basically the article says that you need to identify in the query how to include everything that has any value: Text values consist of alphabetical characters (a..z) and numerical characters (0..9) and use a NOT at the beginning to exclude all the possible values... The "...


5

I am going to cover a few things as I don't know exactly what you're doing here. Create a calculated column to display the first letter of your field using formula - lets call this "FirstLetter" =LEFT([YourFieldName],1) Optionally, you can then use the Group By feature to show a collapsed/expanded list on [FirstLetter] - (see "The By Last Name View" here ...


5

Using SharePoint SQL directly is not supported by Microsoft, so for example the internal structure may change in an update, which may break your query and you will be left to fix it alone. Any updates to the database(s) and Microsoft will no longer provide support for your farm. You can easily use SharePoint list data in SQL Server Reporting Services by ...


5

For SPQuery, use SPQuery.Folder to define the folder: SPFolder folder = list.RootFolder.SubFolders["Folder 1"]; SPQuery query = new SPQuery(); query.Folder = folder; Then, to define content type, you should include the following condition into your Where clause: SPContentType contentType = list.ContentTypes["MyContentType"]; query.Query = "<Where>&...


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

Try the following format YYYY/MM/DD Here is an example. myManageProperty=2014/01/02..2014/02/17 Ref: Problem in KQL with date times and client object model in Sharepoint


5

This is the limitation of REST API Filter that it cannot filter the Hyperlink fields. So whats the workaround? You can use CAML with REST to achieve what you want. The CAML query will be like: <View><Query><Where><Eq><FieldRef Name='URL'/><Value Type='URL'>url</Value></Eq></Where></Query></...


4

I found this to be the easiest way... SELECT * FROM OPENROWSET ('Microsoft.ACE.OLEDB.12.0', 'WSS;IMEX=1; DATABASE=http://portal/sites/Team/;LIST=On Call;VIEW=;RetrieveIds=Yes;', 'SELECT * FROM LIST') You'll need Microsoft Access Database Engine 2010 installed. Here's a connection string reference.


4

It could be achieved by generating url for the asset on the client side and passing it to iframe for displaying asset content in Content Editor web part. Usage Clear ContentLink property Put in Content property of the following code: <iframe width="100%" id="assetContent" frameborder="0"></iframe> <script type="text/javascript"> /...


4

You need to retrieve SPWebApplication.DaysToShowNewIndicator and the build a query to retrieve documents created within that number of days. For more code see Getting the list of new items from code


4

Use the following code: using(SPSite site = new SPSite("http://example/site/")) { using (SPWeb web = site.OpenWeb()) { SPWebCollection webCollection = web.GetSubwebsForCurrentUser(); foreach (SPWeb web in webCollection) { if (web.Properties["SiteCategory"] == "SomeCategory1") {} ...


4

Use SP.ListItem.attachmentFiles to retrieve the collection of attachments that are associated with the list item. How to retrieve list items with attachments using JSOM function getListItems(listTitle,success,error) { var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var list = web.get_lists().getByTitle(listTitle); var items ...


4

You can retrieve it from the DataProvider object. Which is accessible from within your display template. ctx.DataProvider.get_currentQueryState() This returns an object which gives you the whole search query context, like: keyword, sorting, refinement, ... In your case you want to extract the keyword, which you can retrieve from the property like this: ...


4

You should use <Contains> instead of <Eq> in your caml query: var query = "<Query><Where><Contains><FieldRef Name='Category' /><Value Type='Text'>" + value + "</Value></Contains></Where><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query>"; </OrderBy>&...


3

It is possible to create a filter based on the current user. If you're defining a ReadItem method, then you can even do this with the wizard in SharePoint Designer. It's a little more tricky if you want to do the same thing with a ReadList method. This blog post goes into great detail about the process of adding a UserContext filter to a ReadList method. ...


3

Jup, there is a way - with calling Method GetListAndView


3

Follow these steps; Place the standard CQWP onto the page. Export the web part (in the web part pane, click edit -> Export and save the file to your PC) Open the webpart you just exported in Notepad or some other plain text editor Find the property Embed your CAML query into a CDATA section, the above query will now look like this; < ![CDATA[ < ...


3

Probably you're looking for the SPList.Fields.GetFieldByInternalName method. This will allow you to get the field by it's internal name, like this: foreach (string fieldName in list.Views['Viewname'].ViewFields) { var field = list.Fields.GetFieldByInternalName(fieldName) // do whatever you need with SPField object }


3

Strategies for accomplishing this query while working around the constraints: Shorten your query: Do you really need to update 5k records at the same time? Prefer to reduce updates to those actually being changed. If still too big for a successful update then you can break up the records and only update 1k at a time. Change your connection method from ...


3

Your code is fine. Url is property of the item and its not affected by your parameter in GetItems. Test with a field (not property) that is not included in the parameter you pass in GetItems. item["OtherField"] Normally it should throw an exception (ArgumentException).


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