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


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

After some experimenting based on the answer provided by C. Marius I've come to the following conclusion: If you are using ItemUpdating: public override void ItemUpdating(SPItemEventProperties properties) { if (properties.ListItem != null && properties.ListItem.ModerationInformation != null && ...


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.


2

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 SPFieldLookupValue(item["Project_x002f_Task_x0020_Status_"] as String).LookupValue to read the lookup value and int id = new ...


2

You can get Distinct values for email column from your SharePoint list using below mentioned code. i had showed how to insert the distinct email values in drop down list. you can change the code accordingly. try { SPList oList = SPContext.Current.Web.Lists["Your List Nmae Here"]; SPQuery query = new SPQuery(); query.Query = "<OrderBy><FieldRef ...


1

You are right SP doesn't allow to send you attachments from code so instead use Plain .NET classes and write the code here is a sample you may find helpful. You can attach multiple attachments by repeating add() method. MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); ...


1

You can open the site in SharePoint designer , go to your SharePoint List and create a new Display form. In that display form you can re use the same html and JavaScript code of your Survey page. See this blog to know about custom list form.


1

Use ListItem.DeleteObject Method to delete the document item from a Library, for example: var list = ctx.Web.Lists.GetByTitle(listTitle); var listItem = list.GetItemById(listItemId); listItem.DeleteObject(); ctx.ExecuteQuery();


1

You can use following extension methods to update the user/group field: Single User/Group public static void SetUserValue(this SPListItem item, string columnName, int userId) { SPWeb web = item.Web; item[columnName] = new SPFieldUserValue(web, userId.ToString()); } Multiple User/Group public static void SetUserValueCollection(this SPListItem ...


1

For uploading a file into a nested folder you could consider the following approach: ensure the target folder exist using the method provided below upload a file using SPFileCollection.Add method How to ensure a nested Folder exist using SharePoint SSOM internal static class SPFolderExtensions { /// <summary> /// Ensure SPFolder /// ...


1

According to Use OData query operations in SharePoint REST requests, Grouping is not supported. The solution, is to apply grouping for the JSON results returned from REST endpoint. How to group array results using jQuery function groupBy(items,propertyName) { var result = []; $.each(items, function(index, item) { if ...


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

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

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

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



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