Created
June 19, 2015 20:34
-
-
Save pkskelly/cb8f12bc3d6df4bb8310 to your computer and use it in GitHub Desktop.
Extension Method to walk all views in all lists and expand PascalCase view names. E.g. expand "AllItems" to "All Items" in order to keep the %20 chars out of the Url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static partial class WebExtensions | |
| { | |
| public static void SplitPascalCasedViewNames(this Web web) | |
| { | |
| ListCollection projectLists = web.Lists; | |
| web.Context.Load(projectLists); | |
| web.Context.ExecuteQuery(); | |
| foreach (List list in projectLists) | |
| { | |
| ViewCollection listViews = list.Views; | |
| web.Context.Load(listViews); | |
| web.Context.ExecuteQuery(); | |
| foreach (View view in listViews) | |
| { | |
| string viewDisplayName = view.Title; | |
| string newViewName = System.Text.RegularExpressions.Regex.Replace( | |
| viewDisplayName, | |
| "([A-Z])", | |
| " $1", | |
| System.Text.RegularExpressions.RegexOptions.Compiled).Trim(); | |
| view.Title = newViewName; | |
| view.Update(); | |
| web.Context.ExecuteQuery(); | |
| Log.Info("TWExtranetProvisioning", "Changed {0} list view from {1} to {2}.", list.Title, viewDisplayName, newViewName); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment