Skip to main content

Posts

Showing posts with the label List

Get Publishing HyperLink Field Value

The Publishing hyper link field value has some properties that you may want to extract for your use. Properties like: NavigateUrl, Target, Tooltip, Description, IconUrl Just pass in the field value name in your list.  LinkFieldValue pvalue = new LinkFieldValue(footerItem["FooterLink"].ToString());   your pvalue will then contain goodies. QED

Get Sum of Columns in a SharePoint list (Threshold edition)

It is a known fact that once the treshold limit is reached in SP, everything seems frozen.  At this point you have some options. Increase the limit using powershell or from the Central Admin OR Index the columns that you will like to operate on and create views based on those. However programmatically if you want to sum a list that has reached its threshold.  You can do so in batches as hown below:          protected   void  GetSummary( out   long  ideas,  out   long  votes,  out   long  comments,  out   long  transform)         {              long  ideasum = 0;              long columntoSum = 0;              long  commentS...

Create a random item in a list

To create a random item in a SharePoint list:     private   static   SPListItem  GetRandomItem( SPListItemCollection  list) { var  theIDs =  new   List < int >(); foreach  ( SPListItem  item  in  list) { theIDs.Add(item.ID); } theIDs.Shuffle(); Int32 val = theIDs.FirstOrDefault(); SPListItem  randomItem = list.GetItemById(val); return  randomItem; }   The randomization is done here:           public   static   void  Shuffle ( this   IList  list)         {              var  randomNumber =  new   Random (DateTime.Now.Millisecond);              var  n = list.Count;   ...