Questions tagged [splistitem]

Representation of a list item within the SharePoint API.

Filter by
Sorted by
Tagged with
7 votes
2 answers
40k views

Getting an ItemCount with filtering in SP2013 using REST api

I am attempting to return an integer (itemcount) of the items within a SP2013 list. I have done this easily using the stock standard json method. However I have a need of counting the splist items ...
geostima's user avatar
  • 175
25 votes
2 answers
18k views

SPList.Add() vs SPList.AddItem() SharePoint 2010

Using some test code i found out that SPList.AddItem() executes slight faster then SPList.Add() - does anyone know why is it so ? DateTime start = DateTime.Now; SPList ...
SandeshR's user avatar
  • 1,992
21 votes
4 answers
78k views

How to set ListItem Lookup Field value

How do I set a ListItem's Lookup field using code? SPFile file = list.RootFolder.Files.Add(destUrl, iStream, true); SPListItem item = file.Item; item["DocumentID"] = DocID.ToString(); item["...
John Hansen's user avatar
4 votes
2 answers
13k views

How do I get the url for attachments on an SPListItem using C#?

I have an SPListItem for which I would like to get the urls of all its attachments. The urls will be used as part of my custom web part which has an SPList of SPListItem items.
skeletank's user avatar
  • 2,167
9 votes
3 answers
12k views

How to get attachment URL programmatically From SharePoint list item?

How to get attachment full URL programmatically From SharePoint list item? Explanation: I have adding new item with attachment. Now I have to bind that attachment link to grid. When click on that ...
Hitesh Chandegara's user avatar
7 votes
3 answers
21k views

Cannot get field value of list item through JavaScript

I try to get the value of a list item (that is currently selected). I know that I must load it into the context but even with loading the field explicitly I get the following message. Microsoft ...
Shihan's user avatar
  • 589
3 votes
7 answers
9k views

ArgumentException when trying to access SPListItem value

I have a tool to update all items in SP (link replacement). The tool works most of the time but sometimes it throws me an ArgumentException ("Value does not fall within the expected range."). Here is ...
Shihan's user avatar
  • 589
3 votes
1 answer
13k views

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

I have a list that has versioning turned on. Three of the fields are multi-line text boxes which have appending turned on. I want to iterate thru each item in the version history and look for ...
JPHoneyPot's user avatar
1 vote
3 answers
1k views

Exporting SPList

I'm iterating SPWebs and SPLists. When those lists fulfil specific requirements, I would like to export the lists in code, and later import them to another SharePoint environment (using code). How ...
Morten's user avatar
  • 117
0 votes
2 answers
269 views

Auto Populate data from one SP form to another SP form

I've SP 1 form where user's fill Service Area, Secondary Code, Record Series Title fields and when they click Electronic Partial (x) check box another SP 2 form will pop-up and wants the same three ...
Inferno's user avatar
0 votes
1 answer
207 views

Batch Update for 16K Items failing

We are trying to copy contents from one column to the other , However we get request digest error after 6K Items. Below is the code $(document).ready(function () { $("#btnSubmit").click(...
Vivek's user avatar
  • 37
17 votes
2 answers
36k views

Safest way to get a date from Sharepoint into a C# datetime field, using object model?

If I have a Sharepoint list item with a date field. How can I get the field value populated into a c# datetime object? For example: DateTime validfrom = Convert.ToDateTime(item["validfrom"]); ...
JL01's user avatar
  • 1,219
10 votes
2 answers
12k views

PowerShell: Update People Picker Field with domain\Username

I'm trying to get this to work in PowerShell: $spListItem[$ppField] = "domain\username" $spListItem.Update() This gives me the following error: Exception calling "Update" with "0" argument(s): ...
AyKarsi's user avatar
  • 509
5 votes
2 answers
1k views

Problem with CAML SPQuery ItemChildCount result

I know that this query works fine SPQuery query = new SPQuery(); query.Query = "<OrderBy><FieldRef Name='ItemChildCount' Ascending='FALSE' /></OrderBy>"; But my ...
Carls Jr.'s user avatar
  • 199
4 votes
2 answers
12k views

Set default value in a document library column via Powershell?

I'm looking for a powershell script that allows me to set the default value for a column in SharePoint. Thanks
BeauM's user avatar
  • 83
4 votes
0 answers
618 views

SharePoint Online Ribbon Custom Action : Pass multiple itemId in CommandAction's Url

I am developing custom ribbon action using SharePoint hosted app. and this is working fine.When i select any list item and click on custom action then i can get selected list item id. <...
SP Developer's user avatar
  • 3,085
4 votes
1 answer
3k views

Update readonly field using REST API

I am trying to update a list item using Rest API. Following is my code. It works and it updates all fields except "RichMessage" which is a Note field with RichText="TRUE" and readonly. I have tested ...
Medes's user avatar
  • 2,086
3 votes
4 answers
3k views

What is the best way to retrieve random item?

I would like to retrieve random item from SharePoint list. I have these approaches: Get random index and use list.items[randomIndex]. But I think that I retrieves all items from DB in this case. ...
Alexander's user avatar
  • 8,149
3 votes
1 answer
249 views

Content Editor WP or Script Editor WP won't show Content when Saving List as Template

I created a List Template with a Content Editor Web Part in it and I made sure to click the "Include Content" button when I created the template but my list template does not have the Content Editor ...
ermalsh's user avatar
  • 135
3 votes
1 answer
561 views

How to copy data from one column to another column(separate list) while adding the item using EventReceiver?

I have created a sharepoint list named "test" in that I have a column URL as multiline text.While inserting data into that column need to update the same value in another list. I tried by adding event ...
PGP's user avatar
  • 1,115
2 votes
2 answers
2k views

How to update List item with Managed Metadata column using REST or JSOM

How can i update List item with Managed Metadata column using REST or JSOM? Any good sample or suggestion will be appriciated....
user3629354's user avatar
2 votes
2 answers
3k views

Adding list item when user does not have permissions question

I am trying to programmatically add a list item to a SharePoint list. The code works fine when executed by a user with contribute permissions, but does not work when a user has view only. Funny thing ...
heilch's user avatar
  • 107
2 votes
2 answers
2k views

How to add a blog post programmatically?

I'm trying to create a C# script that will allow me to import blog posts from a different system (exported as CSV) into a SharePoint blog. I have found a script for comments to a blog post, but I'm ...
QMKevin's user avatar
  • 1,242
2 votes
6 answers
5k views

How can I auto-increment a column?

I am working on a solution where I have a list with a column named LogIDNumber. For each new entry in the list, I would like to increment the LogIDNumber by one. I could use the ID generated by ...
Jason's user avatar
  • 583
2 votes
2 answers
10k views

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

Scenario: I have a fileupload control in my custom webpart that attaches the uploaded files to the list item. The attachment code is given below: private void UploadAttachments(Helper ...
Muhammedh's user avatar
  • 1,157
2 votes
3 answers
11k views

Possible to load a SPListItem from the item url?

I have a FullTextSqlQuery that is returning the URL for a list item. I would like to create a new SPListItem object from that URL. Is there an easy way to do this, or will I need to peel apart the ...
Abe Miessler's user avatar
  • 6,735
2 votes
1 answer
30k views

I got this error "An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. " when updating a choice field using REST API

I am working on sharepoint on-premises 2013. and i have a cusotm list which contain 2 columns of type "Choice", as follow:-- Now i am trying to copy one list item and create a new list item,...
John John's user avatar
2 votes
3 answers
8k views

Update attachment of list item using rest api is failing

I am trying to update attachment of list item using REST API. I am getting the below error: {"error":{"code":"-2130575257, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The ...
Karthik's user avatar
  • 231
2 votes
2 answers
4k views

Item level permission in SharePoint 2013

I have a list where I want give edit permissions at item level. I am aware of the item level permissions offered by SharePoint. What I am looking for is that I should be able to assign editing ...
Naveen's user avatar
  • 1,892
2 votes
1 answer
433 views

SPListDataValidationException in an event receiver on a task list with Overdue tasks

I have a task list called Finance Department Tasks on this task list i have created an item updating event receiver which checks if all fields in the task list are filled and then sets the task status ...
luckydeveloper's user avatar
1 vote
2 answers
606 views

Find list element when page is loaded

I'm trying to get an element once page has been loaded. However when I put the code in window.onload = function () { my code }; it's not working, without window.onloadit get's the element. here's my ...
user57432's user avatar
1 vote
2 answers
5k views

How to foreach through a list and get distinct values from specific columns C#?

I'm able to loop through a list on sharepoint and get the information I need from selected columns, but how would I loop through a list and get only distinct values from a column in C#. For instance ...
zingwing's user avatar
  • 779
1 vote
0 answers
312 views

SPListItem.Tasks always empty

I have a custom sharepoint (2007) list (named testlist) on which I attached a test workflow (built with sharepoint designer 2007 and named testwf), which only task defined in the 'Actions' section at '...
petauro's user avatar
  • 11
1 vote
3 answers
4k views

Item name / title when creating a folder

I am trying to create a list item with a folder content type by setting it's content type id to a folder content type id. The folder is created successfully but the title is set as 1_.000, 2_.000 etc. ...
Élodie Petit's user avatar
1 vote
3 answers
3k views

update SPList using csv via Powershell

knowing that is possible in PS, exporting SPList items to PS objects(link1 link2) what is the best way, to go into the other way: Create/Update an SPList from an exported csv or format-table.
fallout's user avatar
  • 1,005
1 vote
3 answers
8k views

How to programmatically restart a workflow

I have a workflow linked to my list. Is there any programmatically way to select a list item and restart the associated workflow? Something like: SPListItem item = List.Items.GetById(1); item....
Ziba Leah's user avatar
  • 1,987
0 votes
1 answer
181 views

Unable to add item to my sharepoint list

I try to add an item to my sharepoint list from a custom web part. Is there any mistake in my code? [WebMethod] public static string AjouterDemande() { SPList ...
mokhtar nebli's user avatar
0 votes
3 answers
8k views

How to get an SPListItem from a Search Query Programmatically

I'm querying my Search Server and getting some results... How can i get the SPListItem linked to that object? I tried with many ways, but every method fails.. Here's my code: string ...
Ziba Leah's user avatar
  • 1,987