Search This Blog

Tuesday, May 27, 2014

SharePoint 2013 New Event Receivers In A Nutshell

As a Programmer, knowing how to utilize event receivers is a must have skill in your toolbox. In SharePoint 2013 there were 3 major changes to Event Receivers and 2 minor ones. This blog post is an overview of what’s new.
SharePoint Event Receiver Type Enumeration
The image below shows the progression of additions to the event receiver options in SharePoint. So far nothing has been deprecated, so each progressive release includes all the previous ones.



1. Remote Event Receivers
“Remote event receivers handle events that occur on an item in the app, such as a list, a list item, or a web. These events resemble those in a traditional SharePoint solution, except that they can work with the remote components of the app for SharePoint.” – http://msdn.microsoft.com/en-us/library/office/dn456315.aspx



Here are the key takeaways for remote events.
  • They can only handle a subset of events which have been traditionally available.
  • They are now available for Apps.
  • Because they call an external web service, they are only available in Auto-hosted and Provider-hosted Apps. They do not work with SharePoint-hosted Apps.
2. App Event Receiver
Now that you are familiar with Remote Events, we can now discuss App Events. These special events allow developers some control during the App lifecycle process. They are raised in the following three instances.
  1. After an App is installed.
  2. After an App is upgraded.
  3. While and App is uninstalling.
They are set in Visual Studio in the properties for the App, shown here.




3. Entity Instance Events
Basically this is an event receiver that gives you developer access to three events which occur when External Content Types (registered in BCS) are added, updated, or deleted. Unfortunately there is almost no information regarding this that I can find.
4. Security Event Receiver
I have briefly covered this topic before and now it is being discussed in the larger context of all the event receiver updates to SharePoint 2013. This server side only event receiver (SPSecurityEventReceiver) has received almost no fanfare since SharePoint 2013 was released. It can; however, be utilized in a variety of fashions that are extremely useful. The following are the list of events available to developers in theSPSecurityEventReceiver.
  • GroupAdded – Specifies an event that occurs after a security group is added.
  • GroupAdding – Specifies an event that occurs before a security group is added.
  • GroupDeleted – Specifies an event that occurs after a security group is deleted.
  • GroupDeleting – Specifies an event that occurs before a security group is deleted.
  • GroupUpdated – Specifies an event that occurs after a security group is updated.
  • GroupUpdating – Specifies an event that occurs before a security group is updated.
  • GroupUserAdded – Specifies an event that occurs after a user is added to a security group.
  • GroupUserAdding – Specifies an event that occurs before a user is added to a security group.
  • GroupUserDeleted – Specifies an event that occurs after a user is deleted from a security group.
  • GroupUserDeleting – Specifies an event that occurs before a user is deleted from a security group.
  • InheritanceBreaking – Specifies an event that occurs before an inheritance is broken.
  • InheritanceBroken – Specifies an event that occurs after an inheritance is broken.
  • InheritanceReset – Specifies an event that occurs after the role inheritance is restored.
  • InheritanceResetting – Specifies an event that occurs before the role inheritance is restored.
  • RoleAssignmentAdded – Specifies an event that occurs after a role assignment is added.
  • RoleAssignmentAdding – Specifies an event that occurs before a role assignment is added.
  • RoleAssignmentDeleted – Specifies an event that occurs after a role assignment is deleted.
  • RoleAssignmentDeleting – Specifies an event that occurs before a role assignment is deleted.
  • RoleDefinitionAdded – Specifies an event that occurs after a role definition is added.
  • RoleDefinitionAdding – Specifies an event that occurs before a role definition is added.
  • RoleDefinitionDeleted – Specifies an event that occurs after a role definition is deleted.
  • RoleDefinitionDeleting – Specifies an event that occurs before a role definition is deleted.
  • RoleDefinitionUpdated – Specifies an event that occurs after a role definition is updated.
  • RoleDefinitionUpdating – Specifies an event that occurs before a role definition is updated.
5. List Item Version Events
Lost in all this, is a small update to the SPItemEventReceiver class. There is now a way to handle events when an item or file version is deleted (ItemVersionDeleted) or is being deleted (ItemVersionDeleting). This can be helpful for records management or archival purposes.
Conclusion
The evolution of event receivers patterns the overall evolution of SharePoint itself. There are some “under the hood” (server side) enhancements but the biggest features are App related and cloud compatible. There are many positives to this evolution, my personal favorite is the emergence of the “bring your own web service” architecture. Please leave comments for discussion, any good links, or a reference for the Entity Instance events.

SharePoint Autohosted Application Model Retired>>microsoft trends

In SharePoint 2013, there are three types of application hosting models:
  • SharePoint Hosted
  • Provider Hosted
  • Autohosted


The goal of the Autohosted app model was to provide an easy way for developers to provision Azure resources such as web sites and SQL databases when deploying their custom apps. 

As of Friday, Microsoft has discontinued the Autohosted app model.  The program will officially end June 30, 2014 and if you have developed an Autohosted app, you are encouraged to move it to a provider hosted app model instead.
Incidentally, If you look for information on MSDN on Autohosted apps, you’ll see the following error: