Hot answers tagged

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


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

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


8

Definitely don't want to go the SQL query route because you can easily create an ineffecient query if you don't understand the underlying data model...also possible that you'll develop a query that breaks or becomes inefficient after a CU or SP is applied. CAML queries are very efficient and depending on the scope of your query you have a lot of options. ...


7

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


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

if you can use the same content type across multiple libraries, then you can create a Search Scope ( for the content type scoped @ site collection OR web application level) and user search.asmx or Object model for search API. Search API once indexed queries really fast.


5

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


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

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


4

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


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

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.


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

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

Jup, there is a way - with calling Method GetListAndView


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


3

When you request list items via client object model, the object will return a number of parameters even if you specify none at all. Some of these include title, url, modified date, created date, check out user, etc. You can see these by storing the object as a variable and then using Dev tools to debug the page. You will see there are actually about a dozen ...


3

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


3

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


3

You are missing quotes "" around the value of textbox. Use '<td><input type="text" id="detailsInput" name="Details" value="' + oListItem.get_item('Title') + '" size="35" required="required" /></td>'


3

Your code looks like Server Object Model. Based on my experience on using CAML queries, I can suggest you to get rid of <Query> tags. So update your query as below Query = "<Where>" + "<Eq>" + "<FieldRef Name='ows_PostID' LookupId='TRUE'/>" + "<Value Type='Lookup'>" + ...


3

The way you are fetching items from the list is perfectly acceptable. As an alternative (not necessarily a better alternative, but more flexible), would be to use AJAX and SharePoint Web Services. One thing to note, is there isn't any way to call SP.ClientContext.executeQueryAsync in a loop and retrieve the results. For example, suppose you wanted to loop ...


3

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


3

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


2

Instead of calling context.executeQueryAsync for each item, just add the up to 50 items, then call context.executeQueryAsync after the last one and when the callback is called you're done.


2

If you wanna display the latest items, i think you mean the Content Search Web Part. For this you need the enterprise license as it is not available to the foundation nor the standard edition. If you have a Enterprise license, add it by activating the Search-Driven content feature. SharePoint 2013 feature comparison chart all editions For the Search ...


2

Sounds like you need promises which are in many ways the JavaScript equivalent of the Task class in .NET Using jQuery promises your getList code would look something like this. function getList(listName) { var def = new jQuery.Deferred(); var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); var currentcontext = new ...



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