Hot answers tagged

23

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


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

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

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

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

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

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 code: SPListItemCollection items = spList.GetItems(spquery); repeaterControl.DataSource = items.GetDataTable(); repeaterControl.DataBind();


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

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


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