16 votes
Accepted

REST to get list item by Id

Try this (Excerpt from here): function getListItem(url, listname, id, complete, failure) { // Getting our list items $.ajax({ url: url + "/_api/web/lists/getbytitle('" + listname + "')...
  • 12.2k
13 votes
Accepted

Getting an ItemCount with filtering in SP2013 using REST api

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 ...
10 votes
Accepted

Basic question: Difference between List.items and List.ItemCount in SharePoint

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 ...
8 votes
Accepted

SystemUpdate() in list item update

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

Getting an ItemCount with filtering in SP2013 using REST api

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 ...
  • 28.2k
7 votes
Accepted

People or Group field returning semicolon hash then Name

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(...
6 votes
Accepted

Efficient way to retrieve all list items

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 ...
  • 714
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;
  • 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 ...
  • 2,930
5 votes

Add New List Item With Attachment Via Excel VBA

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 ...
  • 28.2k
5 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(...
  • 1,924
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 ...
  • 9,696
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....
  • 1,735
4 votes
Accepted

Update people or group field of sharepoint list C# code

Change the ConvertLoginName method to: public static SPFieldUserValue ConvertLoginName(string userid) { // Try to get the SPUser value if userid is a user or AD group that has been imported into ...
4 votes
Accepted

Update readonly field using REST API

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

RegEx to validate and replace invalid file name characters from a custom web part file upload control

Found the solution... Here's how I changed my code. private void UploadAttachments(Helper sharePointHelper, IList<HttpPostedFile> postedFileCollection, int itemId) { // Get the list ...
  • 1,159
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-...
  • 4,825
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. ...
  • 4,466
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, ...
  • 4,825
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 ...
  • 5,086
3 votes

Get List Item Version History for each item if specific field was changed

Here is the sample PowerShell code which can be used to export version history to Excel: # ******* Variables Section ****************** #Define these variables $WebURL="http://sharepoint.crescent.com/...
3 votes
Accepted

Item Field returning value with hash character in Itemupdate

By default, a lookup field contains just one value. In this case, the field value is an object of type String, and the string has the following format: Id;#Value Use int value = new ...
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....
3 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["...
  • 31
3 votes

Error:Access denied. You do not have permission to perform this action or access this resource

Make sure Nedia you follow all the steps explained here: Link. Or you can refer this example here. I doubt that there might be some problem with the App permission you are assigning for the app. ...
  • 2,003
3 votes

Query to a list doesn't work

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>" + ...
  • 5,953
3 votes

Drop Down Site column has no value in edit form

I have seen this happen before (when a programmer without SharePoint knowledge 'fixed' a problem with imported/pasted data and emptied/deleted the existing definition of DropDown values The ...
3 votes
Accepted

JSOM 2013 Get Item from List containing all fields

You have to explicity get all fields with var fields= oList.get_fields(); ctx.load(fields) you can then loop over all with var fieldsenum = fields.getEnumerator(); while (fieldsenum....
3 votes
Accepted

How can I see what list items are in what folder?

Find folder name from ServerUrl of your document. It should look like "/{LibraName}/{FolderName}/{fileName.extention}" So the folder is always before the document. Coding Changes cqy....
3 votes
Accepted

Programmatically Get Version Changes for List Item in SharePoint 2013

There's no direct way provided by the server side API to get version changes. But you can compare the fields of different versions: using (SPSite site = new SPSite("http://my.domain.com/")) using (...
  • 3,236

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