A customer had created a huge amount of list views for a large custom list. That’s a good thing. It means they didn’t just created folders
.
They created the views in a random order, but prefixed a number to the view in order for the views to control the order the views are shown by default in SharePoint 2007.
This is all good so far, but after the migration I had a facepalm moment: SharePoint 2010 does not order the views alphabetically like in SharePoint 2007.
In 2010 the views are ordered by the creation timestamp.
There is no apparent way to just reorder them, which i find to be a mistake.
There’s only really two things you can do and that is recreate the views in the order you want them represented or change the timestamp in the Content Database.
The 3 approaches
There’s 3 approaches that I know of:
1: Update the creation date in the Content Database.
Oh noes, you shouldn’t do this. Directly editing the SharePoint databases is a no no.
2: Use PowerShell to clone the views, and then delete the originals.
Techie and fast, but needs us to do it for the users.
3: Use the GUI to copy the views, and then delete the originals.
Users can do this themselves. Not that I am lazy, but if it’s only a couple of views, there’s point in having other people do the work for you.
Personally I would prefer the last solution, since that one lets the content owners do it themselves. It would depend upon how many views there is of course. Asking the content owners to re-create 100 views is a bit much, but 5-10 views should be no problem at all.
I will point you in the right direction with all 3 approaches.
1: Update the creation date in the Content Database
I got this solution here and will only list it in summarized form. To view it in details head for the blog post.
A: Find the List ID for the list that contains the views
You can do this by opening up any view in the list, and then copy the GUID which you can find in the mobile view text right above the bottom OK and Cancel buttons.
Copy the text between the List= and &View= snippets. It should look something like this:
5ed04d31%2D9eb6%2D4dae%2D9f12%2D6f41bfb4871a. Replace the %2D’s with a dash (-) like this: 5ed04d31-9eb6-4dae-9f12-6f41bfb4871a
B: Start up your SQL Management Studio. Go to the correct content database and open up the AllWebParts table.
Create a new query and use this SQL Query snippet:
SELECT * |
FROM [WSS_Content].[dbo].[AllWebParts] |
WHERE tp_ListId = 'Your List ID' |
AND tp_Deleted = 0 |
ORDER BY tp_CreationTime |
This will output table rows with views in the exact same order as the views are shown in SharePoint 2010.
You can then alter the creation date to change how they are sorted.
This isn’t exactly the most risky operation around, but I would prefer other solutions anyway. Maybe because I have no SQL mojo.
2: Use PowerShell to clone the views, and then delete the originals.
The previous blog post also has a PowerShell code to do this and you can also see a MS employee list a script here. Basically it clones views and deletes the old ones.
To be honest, I haven’t tested these solutions yet, but it will work given the right PowerShell code.
Feel free to test the scripts.
3: Use the GUI to copy the views, and then delete the originals.
This is the one I prefer for most situations, since it’s fast, not error prone, and everyone can do it, so you can even send the solution to end users.
For each view in the list do the following, and please remember to do it in the order you wish to create them.
A: Rename the view – maybe just append a character.
B: Click Create View in the View Selector drop down list.
C: Look at the Start from an existing view for the view you wish to rename and click it. This is the real timesaver, and only reason this is a plausible solution.
D: Name the view the original name. This is important in case any users have links directly to the view page.
That’s it.
If you have a better solution, or feedback, don’t hold back!