Skip to main content

Posts

Showing posts with the label CAML

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

Combine complex CAML queries

SPSite site = SPContext.Current.Site; SPWeb oWebsiteRoot = site.RootWeb; SPQuery query = new SPQuery(); List conditions = new List (); foreach (string word in filterval) { conditions.Add(string.Format(" {0} ", word)); } string merged = MergeCAMLConditions(conditions, MergeType.Or); .............................................................   private static string MergeCAMLConditions(List conditions, MergeType type) { try { if (conditions.Count == 0) return ""; string typeStart = (type == MergeType.And ? " " : " "); string typeEnd = (type == MergeType.And ? " " : ""); // Build hierarchical structure while (conditions.Count >= 2) { List complexConditions = new List (); for (int i = 0; i < conditions.Count; i += 2) { if (conditions.Count == i + 1) // Only one condition left complexConditions.Add(conditions[i]); else // Two condotions - merge complexConditions.Add(typeStart + conditions...