Tag Info

Hot answers tagged

8

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


7

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


3

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 Content Type instead of the library.)


2

The fastest would be SPList.GetItems Method (SPQuery, String). However, in case you are referring to large lists and libraries, take a look at Handling Large Folders and Lists.


2

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", headers: { "Accept": "application/json; odata=verbose" }, success: function(data) { if(data.d.CheckOutType == 0) { ...


2

Instead of placing the spItem.Versions in foreach statement. out the versions in a variable. var versions = spItem.Versions; foreach(var item in versions) {} because whenever you call spItem.Versions, SharePoint will make a call to get all the versions.


2

There are two options in sharepoint to delete the listitem: listitem.Recycle() deletes the list item and puts it in the recycle bin listitem.Delete() deletes the item permanently If you delete a document in SharePoint using the User Interface, it’s being moved to the Recycle Bin, so that it can be restored if necessary. Calling the SPListItem.Delete() ...


2

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.


2

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


2

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 SharePoint by the UPS. try { SPUser requireduser = _web.EnsureUser(userid); SPFieldUserValue uservalue = new SPFieldUserValue(_web, ...


2

You can create a view and set following properties Group By = Choice Field Sort = Modified Descending Order Now you can open the view using SharePoint Designer and modify the XSLT to limit the items per group to one.


1

We are in a similar situation. We recognized that in some case our permissions are unqiue but allways the same :) (unique permissions in some flow was always setting the same 2 AD groups). This is helpful as we can move these items down into a folder that has the unique permissions without having to assign it to each item individually, reducing the amount ...


1

You can use Sharepoint paging to get next 5 items on scroll event. In the sample code previous and next actions are defined(for next and last listitems). You need only next button click code . So just define your scroll event and use btnNext click code defined below: var context, web, spItems, position, nextPagingInfo, ...


1

First thing to try: listItem["MyFirstTextField"] = "Blah"; //works fine listItem["TextField_x0020_WithSpace"] = "string"; //doesn't work listItem["MyFirstBoolField"] = true; //doesn't work listItem.Update(); Remove the Properties part.. The above actually consider you provide the Internal name of the fields, the internal name is obviously different from ...


1

When you are adding an item it updates the list item only once. But if you are using the ItemAdded there is another update happen on each list item in order to complete the whole operation. From performance perspective it is bad, but it is safe. Mean I also have seen this. Might be your environment has many event receivers. Try debugging and ensure every ...


1

If you're talking about a list, not a document library, then you can do this: Go to list settings -> advanced settings -> Read access: Specify which items users are allowed to read select: Read items that were created by the user. Same setting for "edit access". On document libraries this option is not available, I don't know why. There you could try ...


1

To make a list look more like a table simply select the list: Click on the Library tab on top and select "Modify View" Scroll down until you find "Style". Click to expand it and select the style you want! Basic Table might do it for you or Shaded which improves readability a lot! In case you just need a table, simply Edit the page: Select the Insert ...


1

You haven't shown us what assemblies you are using so it is hard to say if you are missing any or not. That said I just resolved the exact same error by adding: using System.Linq; to my code. Add this to yours if you don't already have it and see if it resolves your issue.


1

I understand where you are coming from Sivakumar, LINQ to SharePoint is a beautiful thing, especially when coming to SharePoint from other development areas EF/Linq to SQL etc. Unfortunately in my experience it just doesn't work. I have written and deployed solutions using it. Yes it can perform worse than an equivalent CAML query. But the problem I had ...


1

As Robert pointed out using Linq directly on SharePoint lists is not a very good choice regarding performance. The reason is that Linq uses the GetEnumerator method of the IEnumerable interface to execute the Linq query. And every time GetEnumerator is used all SPListItems are retrieved from the database. For 100 list items this means 100 roundtrips to the ...


1

You can try following: List<SPListItem> listItems = list.GetItems(query).Cast<SPListItem>().ToList();


1

You can use _currentContext.Response.Redirect as below: public class TestEventHandler : SPItemEventReceiver { private readonly HttpContext _currentContext; public TestEventHandler() { _currentContext = HttpContext.Current; } // Methods public override void ItemAdding(SPItemEventProperties properties) { var url = new ...


1

your writing to a string that resides on client memory! your not writing to a html control on the page that is on the client so it will never show! how about witin the cewp create a label with JS and then within the method write to it using the innerhtml? first create the control and then add the values to it using the script method you made. <label ...


1

For SharePoint 2013: properties.Cancel is now depreciated, use Status instead. Options for status are: CancelNoError Continue CancelWithError CancelWithRedirectUrl (Obsolete - Default list forms are committed through asynchronous XmlHttpRequests, so redirect urls specified in this way aren't followed by default.) Example: properties.ErrorMessage = "My ...


1

I found a solution to the original problem that was posted here, it took me whole day struggling with xml returned by query. Solution is, In ViewFields, terminate the internal name up to 32 charachters. And then, while getting value, use the internal name terminated up to 32 chars. This is definately poorly tested code by Microsoft pushed in SP 2010. ...


1

Finally i have found the issue! There was a column in the list which i was updating, which had a column validation i removed that validation and found that i'm no longer getting the SPListDataValidationException for items with past dates(overdue). But Now my question is that, is there a way where in you can disable a column validation at run-time in code ...


1

Try this: $urlValue = New-Object Microsoft.SharePoint.SPFieldUrlValue("") $urlValue.Description = "This is an awesome description" $urlValue.Url = "http://MyUrl.com" $item["URL"] = $urlValue $item.update() Reference: http://sharepointnadeem.blogspot.com/2011/10/add-item-to-sharepoint-links-list.html


1

Use SPUtility.CreateISO8601DateTimeFromSystemDateTime to create relevant DateTime string. DateTime firstDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); string firstDayValue = SPUtility.CreateISO8601DateTimeFromSystemDateTime(firstDay); string firstDayValueplus1Month = ...


1

15 workflows will run at a time and the rest will be queued and will run as soon as the number of running workflows drops below 15. By running workflows I mean workflows that are currently using CPU and memory, not all those that have been started before and are in "In Progress" state because some of them may just be sleeping (for example waiting for task ...


1

Technically, views are nothing but saved collaborative markups that describe the contents to be shown. The motivation behind various overloads for GetItems() is to ease the task of getting items and reduce the knowledge you need to use SharePoint Api. If you're not happy with writing CAML you can build a view in the front-end and use its name in the ...



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