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


6

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 Columns. It's not applicable in your CAML query, but if you have more than one 'where', ensuring the first where hits an indexed column can increase efficiency. ...


3

Try this (Excerpt from here): function getListItem(url, listname, id, complete, failure) { // Getting our list items $.ajax({ url: url + "/_api/web/lists/getbytitle('" + listname + "')/items(" + id + ")", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { // ...


3

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


3

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 the values on your target item, and re-enabling the ReadOnly field. Up until now, this is the only working strategy I've found to change read-only fields from ...


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

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

I don't know if it is possible with CAML, but this should work: var emails = List.getItems(querysp).OfType<SPListItem>().Select(item => "" + item["email"]).Distinct();


2

Because you do not Change the value in the field, you just Change the value in your variable. you have to item[fieldID] = "";


2

Avoid using SPContext inside receiver. SPContext doesn't exist in a feature receiver. Instead use the Properties object as it includes a reference to the site or web use following public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; using (SPSite site = new ...


1

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 is also important aspect to be considered. In such cases SystemUpdate() method of SPListItem can be leveraged. This basically updates the content database with ...


1

Before getting to the cause of your issue, let me give you some recommendations for improving your code, because, as it stands, it is hardly readable. Avoid clattering the global scope with unnecessary variables and functions. Look into the module pattern, it will help you keep your code cleaner. You don't really need to use the Function.CreateDelegate, ...


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

Inorder to display error message you need to make few updates in you application web configuration file. <safeMode> tag should be set as <SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false"> <customErrors mode="On" defaultRedirect="/_layouts/error.aspx" /> Now ...


1

I don't think so. ItemUpdated is asynchronous, so by the time it fires, a response has already been sent back to the browser. If you do not have access to the HTTP Request and Response, you can't tell the browser to redirect.


1

You can use SharePoint web services. Below is the snippet I copied from http://stackoverflow.com/questions/22450717/add-and-update-single-item-in-sharepoint-list-via-vba Sub Add_Item(ListName As String, SharepointUrl As String, ValueVar As String, FieldNameVar As String) Dim objXMLHTTP As MSXML2.XMLHTTP Dim strListNameOrGuid As String Dim strBatchXml As ...


1

SPListItemCollection is a collection of SPListItem. Get File object from SPListItem. Example: foreach (SPListItem item in items) { SPFile file = item.File; }


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

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/sites/Sales/" $ListName ="Invoice" $ReportFile = "D:\Invoice_VersionHistory.csv" # ********************************************* #delete file if exists If ...


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



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