1

I have a library where version is enabled, both for Major and Minor versions. And I am importing documents to this library that has a lot of metadata I need to set including the internal fields Author, Editor, Created and Modified. It is working fine for updating documents that are minor version, I use the SPListItem.UpdateOverwriteVersion() after settings the Author, Editor, created and Modified fields after i have checked-in the document with a minor version. And this works fine.

My problem is this approach does not work for Major version documents, then Modified by is set to the account I am currently using to import the documents. If I try to run the SPListItem.UpdateOverwriteVersion() command a new minor version is created after the major version.

Is there anyway to update Major version documents in a library to set the Author, Editor, Created and Modified fields without creating a new minor version?

Edit: Found the solution that works and it is below.

2

So I found the only working solution. As Version is enabled on the library, both for Minor and Major versions, after i have done the check-in of the major version (that I need to change the Author, Editor, Created and Modified Fields on) I disable Minor versions on the library. After this change, I update the fields using SPListItem.UpdateOverwriteVersion(). This results in the major version being updated with the correct values. After the values have been changed, I enable Minor Versions on the library again.

Of course don't have anyone working in the library while you do the migration as it could have unexpected consequences while Minor versions are turned off, if they are expected to exist.

0

For other fields you could simply use SystemUpdate but that doesn't work with "Modified", "Created", etc.

Option 1:

In the migration process upload all the document as minor version, set all the metadata and then publish the documents that have to be in major version.

Option 2:

If you can't repeat the migration as in Option 1 then unpublish the document, do your modifications then MajorCheckIn the document.

  • Naim, thanks for the reply. Option 1: Won't work as the Edited field will be set to the Current user and the Modified date will be set to the current date time. Option 2 does not work as for the same reason as above, as soon as the document is checked in as a major version it get's the current users name in the Editor field and current date time in the Modified field. – Robban1980 Jan 28 '15 at 3:01
  • @Robban1980 Yeah, you are right. Both options are good for Author and Created but not for Editor and Modified. – Naim Murati Jan 28 '15 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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