Right now I have a SPItemEventReceiver that overrides ItemCheckedIn. It checks out the file, creates/marks a hidden field, and checks it back in. The reason for setting a property on the file is to prevent the process from changing the item again; it modifies permissions of the item.

This works, but has some side-effects. The alerts don't work properly due to the Alert system detecting System modifications and the item/file's "Modified By" field gets set to System Account.

Some options include,

  1. Fix/work-around the side effects
  2. Put the data somewhere else
    • put the data in web.Properties
    • create a list in which to put the data
  3. Find a way to tweak the Item properties before the initial check-in
  4. Find a way to detect the a file is new right after it is checked in.

I know how to do 2 and might accomplish 1, but I've struggled finding a way to do 3 or 4.

Update: Versioning is not on, but Checkout is required.

  • Do you have versioning turned on? – Rob D'Oria Aug 23 '11 at 15:31

I would try using SPListList.SystemUpdate() in the event handler. I suspect that you're using SPListItem.Update() at the moment. SystemUpdate() won't change the modified date or user.

|improve this answer|||||
  • I did not realize that was a side-effect of using SystemUpdate. Thanks. – oglester Aug 23 '11 at 19:54
  • No problem, I come across that one in nearly every project... – Andy Burns Aug 24 '11 at 8:15

I found a solution that merge 3 & 4.

  1. In ItemCheckingIn, add a property to the changed properties list. properties.AfterProperties.ChangedProperties.Add(FieldName, value)
  2. In ItemCheckedIn, you can check the property of the item, which will get the value set in ChangedProperties. var s = Convert.ToString(properties.ListItem[FieldName]);

So, to that takes care of setting a value without checking-out/in. the value in this case is a timestamp, which I can detect if it is old or not. If the current time is within a few seconds of the timestamp, then I know the file is new.

|improve this answer|||||

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.