ItemPublished event !!!

I know the title seems weird, but that was exactly the subject of an e-mail message that I have received today from a SharePoint developer asking about the way he can execute some code when a document is published. The guy needs to send out the URL of a document as soon as it is published to a SharePoint group members for taking some actions.

Actually there is no such thing as “ItemPublished” event, the subject of the e-mail was misleading, the guy was searching for such an event but unfortunately SharePoint doesn’t provide it in its object model.

Workaround :

When a document in a library is published, “ItemUpdated” event fires and the only way to detect that an end user has chosen to publish a document is  by checking ModerationInformation in ItemUpdatedevent handler to see if the list item is in a published version or not. Approved is published.

properties.ListItem.ModerationInformation==SPModerationStatusType.Approved

 

Hope this helps..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s