Visual Studio 2013 Screencast from FEDSPUG

FEDSPUG April 2014: Visual Studio 2013 for Application Lifecycle Management and SharePoint with Tim Ferro from Women in SharePoint DC on Vimeo.

Visual Studio 2013 is a monumental leap forward for Microsoft development. There are so many useful enhancements and features that each could be their own session. This session will give an overview of the new features then focus on those related to Application Lifecycle Management, .Net Framework, Mobile, Team Foundation Server 2013, and SharePoint. From project planning, to mobile testing, to inline enhancements from CodeLens, this session will show developers and team leads why Visual Studio 2013 is worth upgrading to immediately!

PowerPoint Slides

SharePoint Saturday Richmond 2014

Click image for PowerPoint

The Evolution of SharePoint Event Receivers from On-Prem to the Cloud
Session and Location: 3pm-4pm in Room 123 Lab

Here’s the code on GitHub

Event Receivers are a fundamental part of SharePoint. They have evolved from server side only to now include App events in the cloud. Knowing how to use them and what features are available for which version of SharePoint is crucial for all SharePoint developers. Drawing on my extensive experience over the past seven years, this session will give every developer a solid foundation for using Event Receivers in SharePoint (both on-prem and in the cloud) built on best practices and real world usage. This session will provide an overview of Event Receivers in SharePoint with specific focus on List Item Event Receivers. You will learn from real world examples, tips, tricks, and hear about how event receivers have been utilized at different clients. I discuss the pros and cons of using Event Receivers as well as compare them to SharePoint Workflows. I will key on the differences between the versions of SharePoint related to Event Receiver functionality and discuss new Event Receivers in SharePoint 2013, including some that work in the cloud. Finally I will show a demo of how to quickly get up and running using Visual Studio and some common use examples.

http://www.spsevents.org/city/Richmond/Richmond2014/schedule

SharePoint Saturday NYC 2014

Click image for PowerPoint.

 

The Evolution of SharePoint Event Receivers

Event Receivers are a fundamental part of SharePoint. Knowing how to use them and what features are available for which version of SharePoint is crucial for all SharePoint developers. Drawing on my extensive experience over the past six years, this session will give every developer a solid foundation for using Event Receivers in SharePoint 2007, 2010, and 2013 built on best practices and real world usage.

This session will provide an overview of Event Receivers in SharePoint with specific focus on List Item Event Receivers. You will learn from real world examples, tips, tricks, and hear about how event receivers have been utilized at different clients. I then discuss pros and cons of using Event Receivers as well as compare them to SharePoint Workflows. Secondly I will key on the differences between the versions of SharePoint related to Event Receiver functionality. Finally I will show a demo of how to quickly get up and running using Visual Studio and some common use examples.

Session and Location info here: http://lanyrd.com/2014/spsnyc/sdcbtw/

SPSecurityEventReceiver – The Missing Technical Reference

SPSecurityEventReceiver

Last Updated: July 2, 2015

Recently I needed to know a lot about SharePoint 2013’s SPSecurityEventReceiver, and the MSDN/TechNet information was sparse. So I did what any thorough (obsessive) developer would do and attached all the relevant methods to multiple SPobjects (SPSite, SPWeb, SPList) to see what happens; then I wrote this blog for future reference.

SPSecurityEventReceiver

“Provides methods to trap events that are raised for security. A customer security event receiver class must derive from this class and overrides the methods for the event types it handles.” – MSDN.

That’s all the explanation you get on MSDN. Clearly this does not do justice to the awesomeness of this Event Receiver. A more thorough description would be “[This Server Side and Remote Event Receiver] Provides methods [in 5 main categories: 1. Group Events, 2. User Events, 3. Inheritance Events, 4. Role Assignment Events, and 5. Role Definition Events] to trap events [Adding/Added/Updating/Updated/Deleting/Deleted/Breaking/Broken/Reset/Resetting] that are raised [at the Site Collection or Site level] for security.“.

When working with Event Receivers you need to know two things right up front: 1. What objects can you attach them to and 2. What exactly do they do. To answer the first question refer to the chart below. Through thorough testing (but by no means exhaustive), I have found this to only work on SPSite and SPWeb objects. Note: Testing was only done via Server Side code in Farm Solutions using SPSite, SPWeb, and SPList objects as hosts. It was not tested against SPContentType, SPFile, or SPWorkflow. There is no SPGroup or SPListItem Event Receiver collection to try either. If anyone can show more, please let me know!

Role Definition Events fire when attached to SPWeb only when that object is the root web of a site collection.

The rest of this blog post answers the second question in detail. I have broken out the important methods into five groups/categories.

1. Group Events

  • SPSecurityEventReceiver.GroupAdded
  • SPSecurityEventReceiver.GroupAdding
  • SPSecurityEventReceiver.GroupDeleted
  • SPSecurityEventReceiver.GroupDeleting
  • SPSecurityEventReceiver.GroupUpdated
  • SPSecurityEventReceiver.GroupUpdating

Group Events only occur when you add, update, or delete groups at the site or site collection level from the master Groups list. This is not for events when you add/update/delete them from existing groups or from sites/lists directly. Those are covered via User Events and Role Assignment Events respectively. If you are using a site collection event receiver (SPSite) then anytime you update this list from any site or sub site this will fire. If you are using a site event receiver (SPWeb) then this will only fire if you navigated to this list via that site (even though it updates the same list). It does not fire if attached directly to a list (SPList) and I speculate this will be true for list items (SPListItem). It was not tested against SPContentType, SPFile, or SPWorkflow. There is no SPGroup or SPListItem Event Receiver collection to try either.

Click to enlarge.

To test the Group Events, navigate to the Site Settings page of the root site in the Site Collection then click the People and Groups link in the Users and Permissions section of links. From there click the Groups link in the left navigation menu. You can navigate there directly by using this link (_layouts/15/groups.aspx). On this page you can Add/Update/Delete groups which will cause the event receiver to fire.

2. User Events

  • SPSecurityEventReceiver.GroupUserAdded
  • SPSecurityEventReceiver.GroupUserAdding
  • SPSecurityEventReceiver.GroupUserDeleted
  • SPSecurityEventReceiver.GroupUserDeleting

User Events occur when you add or delete a SharePoint user or SharePoint group or Active Directory (AD) user or AD security group from an existing SharePoint group such as Owners, Members, or Visitors. This happens for all existing groups in the entire site collection (all sites and sub sites) whether local to one list or global to all. If you deploy at the SPWeb level then it will only fire for events on that site or sub site. It does not fire if attached directly to a list (SPList) and I speculate this will be true for list items (SPListItem). It was not tested against SPContentType, SPFile, or SPWorkflow. There is no SPGroup or SPListItem Event Receiver collection to try either.

Click to enlarge.

To test the Group User Events create a new group or navigate to another group contained within the People and Groups (Owners, Members, Visitors, etc.). Add or delete a user or group to/from this group and you will cause the event receiver to fire.

3. Inheritance Events

  • SPSecurityEventReceiver.InheritanceBreaking
  • SPSecurityEventReceiver.InheritanceBroken
  • SPSecurityEventReceiver.InheritanceReset
  • SPSecurityEventReceiver.InheritanceResetting

Inheritance Events occur when you break inheritance or reset inheritance (re-inherit) on lists, libraries, sites, etc. This works on at both the site collection level (SPSite) and site level (SPWeb). It does not fire if attached directly to a list (SPList) and I speculate this will be true for list items (SPListItem). It was not tested against SPContentType, SPFile, or SPWorkflow. There is no SPGroup or SPListItem Event Receiver collection to try either.

Click to enlarge.

To test the Inheritance Events create or navigate to a list or sub-site that inherits permissions from the parent site. Then simply navigate to the permissions page for the list from the list settings page and break (Stop inheriting Permissions) and reset (Delete unique permissions) inheritance.

4. Role Assignment Events

  • SPSecurityEventReceiver.RoleAssignmentAdded
  • SPSecurityEventReceiver.RoleAssignmentAdding
  • SPSecurityEventReceiver.RoleAssignmentDeleted
  • SPSecurityEventReceiver.RoleAssignmentDeleting

Once you break inheritance, for example on a site or list, Role Assignment Events occur when you add or delete users or groups directly via the permissions page for that site/list/etc. This works on at both the site collection level (SPSite) and site level (SPWeb). It does not fire if attached directly to a list (SPList) and I speculate this will be true for list items (SPListItem). It was not tested against SPContentType, SPFile, or SPWorkflow. There is no SPGroup or SPListItem Event Receiver collection to try either.

Click to enlarge.

To test Role Assignment Events use a list or site that you previously created and break permission inheritance. Then click Grant Permissions to add a user or group. You could also select an existing group and remove it (Remove User Permissions).

5. Role Definition Events

  • SPSecurityEventReceiver.RoleDefinitionAdded
  • SPSecurityEventReceiver.RoleDefinitionAdding
  • SPSecurityEventReceiver.RoleDefinitionDeleted
  • SPSecurityEventReceiver.RoleDefinitionDeleting
  • SPSecurityEventReceiver.RoleDefinitionUpdated
  • SPSecurityEventReceiver.RoleDefinitionUpdating

Role Definition Events occur when you add, update, or deleted Role Definitions such as Design, Contribute, or Read. These events only fire when attached at the site collection (SPSite) level or on the root site of the site collection as a web (SPWeb) event receiver. It does not work for any sub site or non root site. Role Definition Events can not be fired from a sub site because these are inherited from the parent site; however, once inheritance is broken they can not be changed either. Also, it does not fire if attached directly to a list (SPList) and I speculate this will be true for list items (SPListItem). It was not tested against SPContentType, SPFile, or SPWorkflow. There is no SPGroup or SPListItem Event Receiver collection to try either.

Click to enlarge.

To test Role Definition Events navigate to the site collection settings page. Click Site permissions then click Permission Levels. On this page add/update/delete Role Definitions to fire the event receiver.

 

UPDATE: RoleAssignmentAdding event receiver in SharePoint 2013 does not show error page with CancelWithError

UPDATE 2: New information added about which SharePoint objects were tested as hosts, which were not, and which can’t be.

Please comment with any incorrect information or to provide updates. I will update this blog post as a reference. Thanks!

Tim Ferro

SharePoint 2013 New Event Receivers In A Nutshell

As a developer, knowing how to utilize event receivers is a must have skill in your toolbox. In SharePoint 2013 there were three major changes to Event Receivers and two minor ones. This blog post is an overview of what’s new.

The Evolution of SharePoint Event Receiver Type Enumeration

The chart 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.

Note:

 

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 the SPSecurityEventReceiver.

  • 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.

http://msdn.microsoft.com/en-us/library/sharepoint/microsoft.sharepoint.spsecurityeventreceiver_members.aspx

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.

Tim Ferro

CapArea .Net SharePoint SIG 2014 – Visual Studio 2013 for ALM and SharePoint

VS_ALM_SP

Click image for PowerPoint

Visual Studio 2013 is a monumental leap forward for Microsoft development. There are so many useful enhancements and features that each could be their own session. This session will give an overview of the new features then focus on those related to Application Lifecycle Management, Mobile, Team Foundation Server 2013, and SharePoint. From project planning, to mobile testing, to inline enhancements from CodeLens, this session will show developers and team leads why Visual Studio 2013 is worth upgrading to immediately!

IT Predictions for 2014

Below are my three IT predictions for 2014. Please comment with your thoughts on them!

Refocus on SharePoint On-Premise
Rising from the ashes like a Phoenix, SharePoint On-Prem will reemerge in 2014 with renewed focus and an announcement of the next version from Microsoft. Main reasons include: distrust of cloud (thanks NSA), failure to catch on in government space, and complex custom solutions with local infrastructure connections.

DevOps Rises then Plateaus
I really like the technologies and capabilities surrounding DevOps these days. I think that it will continue to gain momentum in 2014 but then plateau off because a lot of organizations are not ready for continuous updates. Places where uptime and stability are paramount will not fully embrace this. They will benefit from all the new enhancements supporting DevOps but will land somewhere between Agile and DevOps. I’m calling this Enterprise DevOps (blog to follow).

Big Data Analytics Dashboards
Here is a massive growth area that I have had on my backlog to explore. Big Data is now mainstream and catching on more and more. The next step is to easily get data out to decision makers. APIs for both .Net code and JavaScript need to be enhanced for easy dashboading of this data. We need the SPServices of Big Data to be invented or a Hadoop webpart for SharePoint.

Tim Ferro

Utilizing and Visualizing Geolocation Data for Powerful Analysis

Utilizing and Visualizing Geolocation Data for Powerful Analysis

Utilizing and Visualizing Geolocation Data for Powerful Analysis by Walton Smith and Tim Ferro

Utilizing and Visualizing Geolocation Data for Powerful Analysis by Walton Smith and Tim Ferro (Booz Allen Hamilton White Paper)

Introduction: Integration with geolocation data and services is an area that is underutilized in Microsoft SharePoint 2010. With the prevalence of SharePoint within both the federal and commercial space, there is a massive amount of information that is not fully utilized by the organizations storing and using it. SharePoint 2010’s Business Connectivity Services (BCS) is an easy way to incorporate external data into SharePoint, as well as its dashboarding capabilities (via out-of-the-box [OOTB] web parts, JavaScript, and custom code), making it a powerful platform for both utilizing and visualizing geolocation data…

Tim Ferro

SharePoint 2010 and Geolocation Data: Screencast

This is the screencast from the July 2013 FEDSPUG meeting where I presented SharePoint 2010 and Geolocation Data.

PowerPoint Slides