views:

745

answers:

1

Hi,

I use the following piece of code to check out and then check in a file. I use IronPython.(Say spfile is the SPFile object)

spfile.CheckOut()
spfile.CheckIn("Done by the script")
spfile.Update()
spfile.CheckOut()
spfile.CheckIn("Done by the script-Second time")

The file is checked in for the first time. But the second time, it throws an exception stating that, the file has been modified at a particular time by SHAREPOINT\system. I find this obscure as I have updated the file already. Any help would be appreciated

+5  A: 

Basically its a transcational issue. You need to get a new reference to the SPfile object in order to refresh the underlying version information and last transaction.

spfile.CheckOut()
spfile.CheckIn("Done by the script")
spfile.Update()

spfile = SPlistItem.File;

spfile.CheckOut()
spfile.CheckIn("Done by the script-Second time")
DJ