Okay quiet but not sleeping… Recently I have been puzzled with this kind of thingy. If you programmatically publish a SharePoint listitem, you’ll get problems in Workflow and more specially at that point if you try to do SPListItem.update() thing. Apparently SharePoint 2007 locks down SPListItem after SPFile.Publish() has been ran.
Now this locking is a bit of odd since after returning from a workflow to back SharePoint, you can do anything to that document but if you try directly after calling that Publish() method you’ll get error saying that “xxx has modified item” or something like that. (Sorry using Finnish WSS 3.0 so errors do come in Finnish, nice thing but sooo much problems when you try to search solutions to those errors….)
So now you might wonder why this is a problem or why in earth I am writing this. Okay consider this scenario: you have a custom made Workflow (Visual Studio style) that copies your splistitem into another location. Then you (or somebody else) wants it to put Version History as a published item. So then you figure (or argue that never going to do this) out how to stamp splistitem as published. Okay then you hit this nice little thingy called SPListItem.SPFile.Publish(). So no problem… After a while you’ll figure out that you need to save some custom information after this publish has been hitten (let’s say that you want to capture the timestamp of this publish call). So next brilliant though is to put this as a column with this item. So now you are getting your feet wet and hitting the drainage sewer.
Feel free to test this or even better, tell me is this “normal” SharePoint behaviour and is there a way to write SPListItem stuff directly after .Publish() –method in a way that it creates a new version of the splistitem instantly.