Article archive

Get User field value

13/07/2017 13:34
 public static SPUser GetUserFromField(SPListItem item, string fieldName) { SPUser user = null; if (item != null && !string.IsNullOrEmpty(fieldName)) { if (TryGetFieldFromItem(item, fieldName) != null && item[fieldName] != null) { var userFieldValue = new...

Find if item is child of Content type

13/07/2017 13:25
public static bool IsItemChildOfContentType(SPListItem item, SPContentTypeId contentTypeId)         {             var itemCtId = item.ContentType.Id;             var isContentType =...

Convert List<string> items to string with separator

13/07/2017 13:21
public static string BuildStringFromList(List<string> list, string separator = ";") {    string separatedValues = string.Empty;    if(list.Count > 0)    separatedValues = list.Select(a => a.ToString()).Aggregate((i, j) => i + separator +...

Get Taxonomy field value programmatically

13/07/2017 13:20
 public static string GetTaxonomyFieldValues(SPListItem item, string fieldName)         {             var values = string.Empty;               if (TryGetFieldFromItem(item, fieldName) != null...

CAML Query Paging

13/07/2017 13:12
We needed to use paging in CAML query and this scenario is not supported, to query list with specific query and get e. g. third page of results. I created two specific queries to list, one to get items count (query without rowlimit) and other empty query with rowlimit to return only appropriate...

Copy generic list without references

28/07/2016 10:04
Sometimes we need to make new generic list based on another list - by query or other. But when we change list2 properties, list1 is also changed. That's why we need to make list1 copy without references. Here is the code to create the copyAdd following code to ListExtensions.cs file public...

Calendar view is missing in View selector

10/06/2016 15:50
If we create SharePoint list calendar view programmatically, there is an issue, this view disappears from view selector in list web part. There is manual step needed to enable/disable View selector in web part properties. Here is a script to do it programmatically by PowerShell (code in C# is...

Get list item url for document

06/05/2016 11:42
In document library, Common Worfklow data as Item URL sometimes returns bullshit strings as http://sever/sites/siteUrl/_layouts/15/WopiFrame.aspx?sourcedoc=/sites/siteUrl/Shared%20Documents/MyExcelFile.xlsx&action=default&OpenIn=browser or others in case of SharePoint listinstead of...

Remove web property from SharePoint

16/03/2016 11:22
Seems like a trivial task, but there was a problem that sometimes property wasn't removed. Here is the method, how to update correct objectspublic static void RemoveWebProperty(SPWeb web, string webPropertyName){ if...

Enable Rating Settings on SharePoint list programmatically

15/03/2016 16:21
public static void EnableRatingOnList(SPList list){ Assembly assembly = Assembly.Load("Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); Type reputationHelper =...
Items: 1 - 10 of 360
1 | 2 | 3 | 4 | 5 >>