0

I have an EventReceiver associated to DocLib template id, triggered at every ItemUpdate. Everytime an SPListItem is publish I want to execute my code.

(Required check out and Content approval are turned off)

So, is the type ItemUpdated the best one in this case? What the best way to check if item was publish?

spregards

2
  • Why not check properties.ListItem.Level == SPFileLevel.Published?
    – Colin
    Commented Jan 22, 2014 at 17:28
  • It won't work for the case when file is checked out. Level in this case will show CheckedOut state. Commented Oct 22, 2015 at 17:05

1 Answer 1

2

In ItemUpdated check

properties.ListItem.File.MinorVersion == 0
3
  • This is Sharepoint :D
    – Sven Mawby
    Commented Aug 22, 2012 at 6:52
  • @per - am I right in assuming this isn't a way to tell whether the event was fired because it has been published? I need a way of testing the beforeproperties against the afterproperties to monitor changes to whether the document is published or not (i.e. need an event to fire on publishing) but cannot find the appropriate field name. Commented Dec 10, 2012 at 14:55
  • 1
    I'd extend this a bit. If file is checked out by current user and this user tries to check using this one - it will be needed compare with 1. For other users - check with 0 will work just fine. Commented Oct 22, 2015 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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