We need to rename documents based on the version number.
I created a custom content type for this, and added it to a document library. I then created a custom site policy and attached it to the content type. The Register method for the Policy sets up an EventReceiver.
I have tried catching the itemadding, checkingin, checkin, update, updating events.
The code for the event handler is:
DisableEventFiring();
base.ItemUpdating(properties);
SPListItem li = properties.ListItem;
string prefix = GetPrefixForPolicyInstance(li);
SPFile file = li.File;
int versionId = file.MajorVersion;
file.Item["Name"] = prefix + versionId.ToString() + file.Name;
file.Item.Update();
When I do this the filename gets updated - but then word 2007 complains that the file no longers exists - some sort of mismatch in that it saved A but the data back is B.
How can I do what I need to do