Obsivus
Obsivus

Reputation: 8359

How can I stop the item from getting published?

I have a eventreciever for item updates that have following method:

public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);

            if (!HandleEvent(properties))
            {
                return;
            }

            var item = properties.ListItem;

            EventFiringEnabled = false;

            if (IsPublished(item))
            {       

            }

            EventFiringEnabled = true;

} 

Here is the method for IsPublished:

private bool IsPublished(SPListItem item)
{
    return item.Level == SPFileLevel.Published;

}

I need to somhow stop it from publishing, how can I do that??

Upvotes: 1

Views: 227

Answers (1)

Raymond
Raymond

Reputation: 175

public override void ItemCheckingIn(SPFeatureReceiverProperties properties)
{
  base.ItemCheckingIn(properties);
  //Major Version
  if(..){
   properties.Cancel = true;
   properties.ErrorMessage = "you cannot publish!";
  }

 }

Upvotes: 1

Related Questions