16

Try this (Excerpt from here): function getListItem(url, listname, id, complete, failure) { // Getting our list items $.ajax({ url: url + "/_api/web/lists/getbytitle('" + listname + "')/items(" + id + ")", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { // ...


13

The ItemCount function could be applied to List resource, for example: /_api/web/lists/getbytitle('<list title>')/ItemCount but not to ListItemCollection resource You could consider the following options of getting items count for list items: Option 1 How to return items count from json result: var endpointUrl = _spPageContextInfo....


10

AS PER MSDN SPList.ItemCount: The value of the ItemCount property includes folders within a document library, as well as files within subfolders. The value of the Count property of the SPListCollection class does not include folders. SPListItemCollection.Count: Gets the number of list items in the collection, excluding folders. BUT Although it's ...


8

If fetching of item["ID"] instead of 'Title' works AND If you are using the SPQuery object. Then, include the columns that you want to fetch in the ViewFields property of SPQuery. This will resolve your issue. Reference: http://discoverlars.wordpress.com/2012/01/24/argumentexception-value-does-not-fall-within-the-expected-range-error-using-fields-on-...


8

We might have to manipulate/update the data without changing the Modified or Modified By fields to meet the business needs and also retaining the document/Item status without incrementing the version is also important aspect to be considered. In such cases SystemUpdate() method of SPListItem can be leveraged. This basically updates the content database with ...


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

The objects you get from $list.Folders are SPListItems not SPFolders so the ListItems property gives the Lists ListItemCollection not something for the folder. To get the SPFolder you have to access $folder.Folder. If what you're working with is a document library, then it's easy just access $folder.Folder.Files and you'll get the files in the SPFolder, ...


6

When you query /_api/web/Lists/getbytitle(\'Items\') basically it returns SPList object. That object as ItemCount property. The value of the ItemCount property includes folders within a list/document library, as well as items/files within subfolders. For filtering we need to apply filter on Items so query /_api/web/Lists/getbytitle(\'Items\')/items?$filter=...


6

Make sure that the column you include in the where clause is defined as an indexed column in SharePoint. You can check by going to the list you're querying and into List -> Settings -> Indexed Columns. It's not applicable in your CAML query, but if you have more than one 'where', ensuring the first where hits an indexed column can increase efficiency. ...


6

get the item in SPlistitem and then get value from it. For ex = Splistitem item = list.getitembyid(1); var x = item.ID;


6

In SharePoint ID is a counter and always incremental. Even though you delete item, it is never going to occupy the blank ID. It always keeps on incrementing. Also list.Items always return SPListItemCollection. But when you delete the item from List, the index of Item keeps on changing. For example, you had 10 items in list list.Items[9] will give you the ...


5

You need to use the $expand option in your query string. siteUrl + "/_api/lists/getbytitle('" + listName + "')/items?$select=NameOfLookup/FieldYouWant&$expand=NameOfLookup/NameOfFieldYouWant" So yours would be: "/_api/lists/getbytitle('" + listName + "')/items?$select=$expand=status_x0028_test_x0029/Title&$expand=status_x0028_test_x0029/Title ...


5

You can use SharePoint web services. Below is the snippet I copied from https://stackoverflow.com/questions/22450717/add-and-update-single-item-in-sharepoint-list-via-vba Sub Add_Item(ListName As String, SharepointUrl As String, ValueVar As String, FieldNameVar As String) Dim objXMLHTTP As MSXML2.XMLHTTP Dim strListNameOrGuid As String Dim strBatchXml As ...


5

Using SPList.Items property is bad practice. Each time the property is accessed, it requests all items with all fields from database. Instead you should always use SPList.GetItems(). SPList.GetItems(params string[]) - you can use it to load only the fields that you need. As far as I remember it'll only return items in the root folder of the list. SPList....


5

I never use the SPListItem.Url property, as list items don't really have a user browsable URL. They only have an ID, and the list that contains them has a display form (list forms may also change over time). The URL of an item is used internally by SharePoint but is never shown/used by the users. So, I always use code such as: Uri webUri = new Uri(web.Url)...


5

Yes, this is possible in SharePoint 2013. You can follow the below steps: Go to the list where you want to assign item level permissions. Select the Item in which you have to provide the permissions. Then click on the ellipses -> Advanced -> Shared With and a new pop up will appear. In the pop up, click on the Advanced button. The permission groups for ...


4

So you have UniqueId of the item and the Url of the library, right? You can get the item in one of the following ways: Get the list from the Url SPList list = web.GetList("http://mysharepoint.be/MYDOCUMENTSLIBRARY"); SPListItem item = list.GetItemByUniqueId(yourGuid); Get the list form the Url of a webpart page that has a web part for your list as first ...


4

If you want to get the collection of "field_name + field_value", you can try: var fieldValues = currentItem.get_fieldValues(); It returns an object, the object key is field name and the object value is field value.


4

You are getting the field, not it's value. To get the value use this: item["Title"]


4

Explanation Based on your affirmative response to my comment, I've gone ahead and wrote this using the JSOM API. The script works by disabling the ReadOnly property on the RichMessage field, updating the values on your target item, and re-enabling the ReadOnly field. Up until now, this is the only working strategy I've found to change read-only fields from ...


4

Found the solution... Here's how I changed my code. private void UploadAttachments(Helper sharePointHelper, IList<HttpPostedFile> postedFileCollection, int itemId) { // Get the list SPList listToUpdate = Helper.GetList(this.BackendListName); SPListItem itemToUpdate = null; // Get the existing item to update itemToUpdate = ...


4

If both lists are same, you can use SharePoint designer workflow to copy list item from one list to other. Below link may help you to get started: http://blogs.salmanghani.info/copy-item-workflow-using-sharepoint-designer-2010/


4

There is a concept of IN Query in Sharepoint where you can use CAMl to hit with multiple conditions . Below is a code snippet where I've used it to create IN query for 1000 ID's. SPQuery queryEpisodeDocs = new SPQuery(); if (count > 500) //count is the number of ID's you have { ...


4

I am assuming that you have Employee list(Parent list) and Access card list (Child list) with lookup column "Employee" from parent list. To force one to one relationship, in child list lookup column, select the option "Enforce Unique Values". This will make sure that only one item added in child list per employee.


4

As far as I know, it's impossible to validate only if particular field changes. It's by default that column validation would validate the data in this column when items are saved to this list. I could achieve your first requirements using this formula: =IF(ISBLANK([Date]),TRUE,[Date]>=TODAY())


3

If you go into the advanced settings for the list you can choose to ensure that users only see and edit their own items. Getting the items from the list for each user should not be an issue as long as each user does not have 1,000s of items.


3

Instead of creating a new SPFieldUserValue find the one in the SPFieldValueCollection you want to remove like this: private static void DeleteUserFromList(SPUser userDeleted, string fieldName, SPListItem item, SPWeb sPWeb) { SPFieldUserValueCollection Users = (SPFieldUserValueCollection)item[fieldName]; SPFieldUserValue DeletedUserValue = Users....


3

All answers are not safe, when the field is null. This can happen, when a field gets later added and already items are in this list. This is a safe cast: bool? showTitle = properties.ListItem["ShowTitle"] as bool?; if (showTitle.HasValue && showTitle.Value) { }


3

In SharePoint 2013 ListID, ListItemID properties can be added to the result set of KeywordQuery, SearchExecutor: var properties = keywordQuery.SelectProperties; properties.Add("ListID"); properties.Add("ListItemID"); See: Overview of crawled and managed properties in SharePoint Server 2013 https://technet.microsoft.com/en-us/library/jj219630.aspx


3

If you look at database Wss_ContentXXX to table dbo.AllUserData in fields tp_Modified and tp_Created milliseconds always equals to 000. For seconds you can use the following formula with a calculated field: =TEXT(Created,"dd-mmm-yyyy HH:MM:SS")


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