Skip to main content
6 votes
Accepted

What are the best practices to get all items from SPList

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(...
dstarkowski's user avatar
  • 1,932
6 votes
Accepted

item[ID] doesn't return item[ID]

get the item in SPlistitem and then get value from it. For ex = Splistitem item = list.getitembyid(1); var x = item.ID;
Muskan's user avatar
  • 886
6 votes

item[ID] doesn't return item[ID]

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 ...
ThinkB4Code's user avatar
  • 2,970
5 votes
Accepted

properties.ListItem.Url inside an event receiver is working well for discussion board items, while it fails for custom list (url will end with _.000 )

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 ...
Evariste's user avatar
  • 9,731
5 votes

Item level permission in SharePoint 2013

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....
Anand's user avatar
  • 1,745
4 votes
Accepted

How synchronization 2 SPList with workflow?

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-...
P S's user avatar
  • 4,817
4 votes

Proper way to evaluate/get status of boolean field when looping through SP List with code

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["...
Scalios's user avatar
  • 41
4 votes
Accepted

Query SharePoint List by multiple item IDs

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. ...
Taran Goel's user avatar
  • 4,474
4 votes
Accepted

Update attachment of list item using rest api is failing

Unfortunately there is no API to overwrite the list attachment, so you need to delete the attachment first before uploading it. Try the below sample code: function checkFileExists(){ $.ajax({ ...
Gautam Sheth's user avatar
  • 30.9k
4 votes
Accepted

How can I force one to one relationship in SharePoint lists?

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, ...
P S's user avatar
  • 4,817
4 votes

Column validation for past dates

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 ...
Michael Han's user avatar
  • 5,201
3 votes

How to get an SPListItem from a Search Query Programmatically

In SharePoint 2013 ListID, ListItemID properties can be added to the result set of KeywordQuery, SearchExecutor: var properties = keywordQuery.SelectProperties; properties.Add("ListID"); properties....
gnagypal's user avatar
3 votes
Accepted

Get SPListItem ItemsData

This code should work: (web is a variable that references the web object) SPFieldUserValue value = new SPFieldUserValue(web, item["AssignedTo"].ToString()); if (value) { ...
Ahmed Mahmoud's user avatar
3 votes
Accepted

How to store IP Address and very large int account numbers in list? What types are best

Single line of text can store 255 characters. So you will be good even in case of IPv6. One drawback of storing interger in text field is that you will lose the out of the box ability to apply ...
Amal Hashim's user avatar
  • 28.3k
3 votes
Accepted

How would I get the Fields which are enabled and the position from left

Use the below code, it will give you the list of Fields that are in Display in the View and the postiion from left. public static void GetViewDetails() { ClientContext context = ...
Nagarajan Muthukumar's user avatar
3 votes

Find list element when page is loaded

Here's a small utility to attach properly to the SharePoint lifecycle. You use it like this: window.LifeCycleHelper.AttachToLoad(function(){ alert('Hello World'); }); Utility: //use an IIFE to ...
Mx.'s user avatar
  • 3,333
3 votes

Query SharePoint List by multiple item IDs

You can use CAML as a query language to tell the query which items you want get. Have a look at: https://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx?cs-save-lang=1&cs-lang=...
Stefan Hennicken's user avatar
3 votes
Accepted

SP - Delete list item and folders in Recycle bin with C#

To send items to Recycle bin, you can do like this: //Custom List if (list.BaseType == SPBaseType.GenericList) { SPListItemCollection coll = list.Items; foreach (SPListItem listitem in coll) ...
Cecilia's user avatar
  • 984
3 votes

Getting List Items in Javascript

Changed var query = SP.CamlQuery() to var query = new SP.CamlQuery() problem solved. Whoops.
ICW's user avatar
  • 434
3 votes
Accepted

Getting List Column Does Not Exist Error When The Column Very Clearly Exists

Go in and check the internal name of the column. You can do this by editing the column and looking at the Field parameter in the url. In my case when I created a column with that name the internal ...
Rothrock's user avatar
  • 3,010
3 votes
Accepted

Get multiple list-items by URL with one Rest API request

What @Ekta said: Just get all the items, then in javascript you can parse out the array by id. Let's say you had an array of all the listitem ids named itemidarray such as var itemidarray = [1, 5, ...
Mike's user avatar
  • 12.2k
3 votes

Get multiple list-items by URL with one Rest API request

There are 2 different approaches to read items from List using REST API If you are reading items from single list with different conditions matches your results then use filter operation as shown in ...
Venkat Konjeti's user avatar
3 votes
Accepted

How to change the list name using c#?

using (var oSite = new SPSite(fundURL)) { using (var oWeb = oSite.OpenWeb()) { var listWithArticles = oWeb.Lists.TryGetList("Articles"); if(listWithArticles != null) ...
Goshky's user avatar
  • 2,058
3 votes

Fetching and displaying more than 5000 list items

The 5000 items threshold, restricts the number of items you can fetch using one query/view. You can read more than 5000 items by fetching the items in batches or provide pagination. Here is another ...
Ram's user avatar
  • 723
3 votes
Accepted

How to properly use GridView to create items on SharePoint Lists?

Try below code private void AddGridRecords(int ID) { try { SPWeb web = SPContext.Current.Web; SPList List = web.Lists["FORM D List"]; web....
P S's user avatar
  • 4,817
3 votes
Accepted

What is the client side equivalent of SPAttachmentCollection.Recycle method

You need to append recycleObject to the attachment endpoint to send them to the recycle bin. The REST endpoint would be as: .../getItemById(20)/AttachmentFiles/getByFileName('test.docx')/...
Gautam Sheth's user avatar
  • 30.9k
3 votes
Accepted

Folder Name not showing with powershell

The correct field value to use is FileLeafRef for folder names Modify your code as write-host $item["FileLeafRef"] should output the folder name
Gautam Sheth's user avatar
  • 30.9k
3 votes

SPfx Show More button with a different approach?

While willman's critique of your code is correct (I was going to add all that into my answer as well - you should definitely be saving that data in state, not a class property, and relying on the fact ...
Dylan Cristy's user avatar
  • 12.7k
2 votes

REST to get list item by Id

Official documentation from MS provides all possible examples. https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-rest This will return an individual ...
AtariPixel's user avatar
2 votes
Accepted

SP07 - How to get SPListItem Author and Last Editor

Author is the person who created the item. It is assigned once the item is created and never changed. Editor is changed every time item is modified. Better use SPFieldUserValue to retrieve SPUser. ...
user1853141's user avatar

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