I have 2 question here,
Scenario: I have created a document library with my own list definition, having the default document library settings. There are quite number of document libraries created using my definition. Now I wanna change the version settings to limit number of major versions to 5.
I came across "MajorVersionLimit" List element property of Schema file, unfortunately this is available only for Content Migration schema alone. It didn't work for me.
Question 1: Is there any simple mechanism where I can enable such settings across my site collection?
I know I can write piece of .NET code to change this. Question 2: If I do this, Will it break the list from its list definition?
Thanks in advance. ~Yuva
-
I don't know how you can set these values via the configuration file, but they are exposed on an SPList object. So the trick is to find a way to capture when a new list is created from your template, and then set the fields (SPList.MajorVersionLimit and SPList.appropriately) appropriately.
I haven't tried this, but here's where I'd start.
- In the ListTemplate element configuration file, set the 'NewPage' property to a aspx page that should get displayed when the user clicks the 'create' button in the UI.
- In the code behind for that page, create the list manually (using the OM) and set the properties.
There may be a better way, but I don't see it. Good luck.
-
The MajorVersionLimit argument does work with schema.xml. Just remember to check the Create a version each time you edit a file in this document library? option.
-
In my opinion the easiest way to modify existing webs is to write a small PowerShell script setting the spWeb.MajorVersionLimit, some thing like this:
`#Set up connection
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
for($i=0; $i -lt $spSite.AllWebs.Count;$i++)
{
$spWeb = $spSite.AllWebs[$i] for($j=0; $j -lt $spWeb.Lists.Count;$j++) { $aList = $spWeb.Lists[$j] if( $aList.Title -ceq "dokumenter") # case sensitive { if( $aList.EnableVersioning -eq $false) { $aList.EnableVersioning = $true $aList.MajorVersionLimit = 5; $aList.Update() } } }`
-
It's actually not true, you can set MajorVersionLimit through Scheme.xml (as List element attribute), it worked perfectly well for me . There is no support for these attributes through intellisense.
The solution was described on Doug "bobthebuilder" McCusker blog ( http://suguk.org/blogs/sharepointhack/archive/2008/01/14/7809.aspx )
0 comments:
Post a Comment