1

Is there a way to change the version from a minor to a major version when a document is initially uploaded to a document library?

Currently, when a document is uploaded it's set to version .1. We would like the initial documents start with a major version such as 1. It doesn't seem right that the uploaded document would start with a minor version given it's the first time the document appears in the library? Also, is there a global setting that will allow me to change this or do I have to go through every single library to change it?

Thanks in advance, Robert

2 Answers 2

2

You can elect not to use minor versions at all in the list/library settings, at which point the initial upload would revert to 1.0.

I suppose you could write an event receiver or kick-off a workflow that publishes the document, which would set it's version to 1.0, but that feels kind of hacky to me.

Other than that I don't see that you can do much. The Version number can't be manipulated programatically without going directly to the database and that's a big no-no.

1
  • Pretty much what I'd suggest, not using the minor/major versions would be the first option, otherwise you are stuck automating workflows.
    – MichaelF
    Aug 10, 2011 at 18:22
1

You can do this by placing the following code in an ItemAdded event receiver on the document library:

if (list.EnableMinorVersions)
   item.File.Publish("Auto publish");

This will publish the document if minor version are enabled on the doc lib. Publish in the sense of creating a new major version.

As far as I know there is no way to set versioning globally. It is a property of a list instance. Best way around it would probably be to create a list definition for the doc lib with the wanted versioning settings and use that to create the doc libs. Also, you have the option to change the versioning settings programatically.

1
  • Not sure whether to +1 this or not since it's more or less the answer I gave.
    – Rob D'Oria
    Aug 10, 2011 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.