Hot answers tagged

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


7

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


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

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


6

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


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

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

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

I just wanted to add that you could always do it like this Search only site collection and only doc or pdfs {?{searchBoxQuery} (FileType=docx OR FileType=pdf) Path:{Site.URL}}


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

You'll need to make sure that your custom column is a Managed Property in your Search Schema. By default, all site columns are also created as Managed Properties, but if you created the custom column in the document library itself, it won't be in the Search Schema as a Managed Property, it will just be a Crawled Property. In Central Admin, go to your ...


3

Try the following code: SPListItemCollection items = spList.GetItems(spquery); repeaterControl.DataSource = items.GetDataTable(); repeaterControl.DataBind();


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

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

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

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

Try wrapping your entire query with {? your query }.


3

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


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

I believe you already know how CSOM works in SharePoint though I am adding a little explanation. CSOM sends XML request to Client.svc and get JSON response. So when you write something like following, then it requests for all properties in XML request. context.Load(myList, items => items.Where(item => item.Hidden == false) Now consider following ...


3

Edit the Page that stores the search results Edit the "Search Results" web part Select "Change Query" In the Query text box, look for {searchboxquery} If you don't see that, the search box query will not be included in the search results.


3

If you do that Search query from the search center then you can use the resulting url. It will look something like: [url for your search center]?k="search term"


2

According to msdn article you posted it looks like it is hard limit. Can you split long query into multiple smaller and merge results?


2

For a such scenario the following approaches could be considered: Override Query [ToolboxItemAttribute(false)] public class MyAggregatedDocuments : Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart { protected override void ConfigureDataSourceProperties() { // only perform actions when we are trying to show ...


2

Use CAML, it will give you better performance. You should skip the <Query> And </Query> From your SPQuery.Query, so just start with <OrderBy> So query.Query = "<OrderBy><FieldRef Name='Sequence Number' /></OrderBy>"


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