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 + "')...
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
Exception when getting the value of field in SPListItem
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 ...
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 ...
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
loop splistitem in folder in powershell
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 $...
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 ...
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;
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 ...
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 ...
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(...
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 ...
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....
4
votes
Alternative to CSOM ListItem.get_item
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 ...
4
votes
Accepted
get value from splistitem
You are getting the field, not it's value.
To get the value use this:
item["Title"]
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
...
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
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
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
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 ...
3
votes
Need to have a default word document inside a new item form for every list item
What you have described is the functionality of Document Libraries. You can provide a custom document template for the library. (It may make more sense to provide a custom document template at the ...
3
votes
Accepted
SPServices is the Document Checked Out SP2010
You could use SP.File.checkOutType property to determine whether document is checked out of a document library
REST
$.ajax({url: "/_api/web/getFileByServerRelativeUrl('" + docUrl + "')/checkOutType"...
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["...
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
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
splistitem × 519list × 95
development × 70
splist × 49
2013 × 43
2010 × 43
sharepoint-enterprise × 42
javascript × 41
sharepoint-online × 40
sharepoint-server × 35
powershell × 34
sharepoint-foundation × 30
event-receivers × 27
workflow × 23
updatelistitems × 23
document-library × 21
client-object-model × 17
sharepoint-designer × 16
splistitemcollection × 16
permissions × 15
custom-list × 15
spfield × 15
2007 × 13
rest × 12
jsom × 12