Options for Branding SharePoint Online (Office 365)

*Updated on December 10, 2014 with info directly from Microsoft!

“Right now we are working with a bunch of SharePoint MVP’s who are providing all of the common branding scenarios they have. The intention is that we will provided supported hooks to achieve these. And not just across SharePoint but suite wide. We have a list of 30 the engineering team are researching right now based on code they’ve been provided by MVP’s. [...] There are no promises right now on when engineering will have the hooks. But it’s a step in the right direction.” – Jeremy Thake

 

BrandingO365

There’s been some interesting chatter going on lately about what the options are for branding Office 365. Recently Microsoft has updated their guidance against using custom master pages, custom site templates or sandboxed solutions! (Newly updated guidance as of December 9, 2014 here.) It seems as if is confirmed that something new will be coming in the future but for now we are stuck in limbo. Companies aren’t going to sit around and wait for the next option to be revealed, they are in need of solutions and guidance immediately. I have done a good amount of research over the past couple weeks and I have found the following options to be available right now:

  1. Don’t custom brand – This is not what you want to hear but for now it is the best option. Wait for future enhancements or use all out of the box options (master pages, themes, etc.).
  2. Use the theming engine – “Designers can use the theming engine to create custom themes, which are called composed looks in SharePoint 2013 and SharePoint Online. At a minimum, themes define colors. A complete theme defines colors, fonts, a background image, and the associated master page, and a .preview file that defines how the .master page is previewed. Developers can write remote provisioning code to apply themes using the remote provisioning pattern.”Source
  3. Brand like you always have before – Design manager, custom master pages, Apps for deployment, etc. HERE’S THE PROBLEM: Microsoft is continually rolling out updates, including to the 2 default master pages. This means if you change them or roll out your own, you will need to compare yours to theirs on a frequent (weekly?) basis. Then you will need to update your master page with changes made to the default ones so that your users can take advantage of all the new features.
  4. Just CSS and JavaScript – After a good amount of research, I have found a middle ground. What if you could have custom CSS and JavaScript running on every page without having to deploy a custom App or use a custom master page? Once you enable the Publishing Feature on your site, you can utilize an Alternate CSS file for all your sites (Site Settings > Look and Feel > Master Page > Expand the Alternate CSS URL section). That just leaves the custom JavaScript. This blog shows step by step how to get a custom JavaScript file running on all pages in SharePoint Online using only JavaScript/JSOM. You are still going to need to check the site for affected CSS/JS changes but it should be on a more “as needed” basis.

What do you think? Are there other options or variants I am missing? Please let me know so I can update immediately.

Tim Ferro

JavaScript on Every Page of SharePoint Online (Office 365)

Tim Ferro on GitHub (vball525)

BLUF: Here’s a single JavaScript (JSOM) file you can use to add a JavaScript file reference on every page in SharePoint Online (Office 365) without an App!

Scenario: You need to run some JavaScript on every page in your site collection in SharePoint Online (Office 365). You don’t want to use a custom master page (because Microsoft is now recommending you not do this anymore), AND you don’t want to have to write an App to do something this simple. I was in this exact situation last week and I wanted a quick but effective way to handle this situation. I kept thinking that there has to be an easy way to do this without an App or a custom master page. GOOD NEWS, THERE IS.

JSOM to the rescue! After a bit of searching around the Internet, I found a couple of great references: here and here. They were so close but I needed to do a little tweaking to get it just right. I just wanted ONE single file that does everything for me. When a simple, single file solution didn’t exist, I created one (mostly from the previous references) and posted it to my GitHub account here! *Note I could not find a way to get CSS with HTC references working (example here). Please let me know if you can and how.

Step 1: Download RegisterJavaScript.js and alert.js (this is the file you want registered on every page in Office 365) from GitHub. Important! Comment out the following lines, then save.

Step 2: Upload them both to your Office 365 tenant. Upload the alert.js file to the “Site Assets” document library. Upload the RegisterJavaScript.js file to any document library you wish.

Step 3: Create a new page. Call it anything you wish, as you will delete this after one use. I called mine “RegisterScript”.

Step 4: Add a Content Editor Web Part to the page and link it to the RegisterJavaScript.js file. Be sure you followed Step 1 and commented out the lines.

Step 5: Save the page, refresh the page, and make sure there are no errors.

Step 6: Uncomment the lines you commented out earlier and in a different tab reupload to the Site Assets library.

Step 7: Refresh the RegisterScript page again. You should see a success pop up!

Step 8: DO NOT REFRESH THE PAGE. Click ok. Close that tab. Do not save anything. From the other tab you have open, click the link for Site Contents. Navigate to the document library where your new page is and DELETE IT. If it is successful, you only need to run this one time.

Step 9: Verify via JavaScript tools. For this example I will show the F12 Developer Tools for Internet Explorer.

DONE! All-in-one file using JSOM you have registered your JavaScript file in SharePoint Online (Office 365) on every page. I have tested this in multiple Office 365 tenants.

I hope this is easy, simple, and helps. Please leave comments or feedback so that it can help others.

Tim Ferro

JavaScript Libraries for .NET & SharePoint Developers

JavaScript LogoWhether you are developing for Office 365, SharePoint 2013, ASP.NET, or another web option, these days you are going to need some “go-to” JavaScript libraries to enhance your solutions. No matter what project I am on, over the past few years these are the JavaScript libraries I have learned to use and integrate with great success: jQuery, SPServices, jqPlot, and DataTables. I highly recommend them all and suggest you check them out ASAP. Additionally, if you are a .NET SharePoint developer who wants to get up to speed with JavaScript and jQuery for SharePoint, this session from Rob Windsor is a must watch: http://blogs.msmvps.com/windsor/2014/07/28/session-recording-javascript-and-jquery-for-sharepoint-developers/.

#1 jQuery - This is the “must have” JavaScript library for web development. It does a ton of useful things, is cross browser tested, and a lot of good libraries (plugins) are dependent on it. It is worth it for the cross browser functionality alone.

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

#2 SPServices - This jQuery plugin is a must have for SharePoint developers. It works for SharePoint 2007, 2010, 2013, and Office 365. Data access is so much easier with this plugin! And now there is a Visual Studio Intellisense file for SPServices!

SPServices is a jQuery library which abstracts SharePoint’s Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.

#3 jqPlot – Whether you need to replace the missing Chart Web Part or you want an easy to use charting jQuery plugin, this is the library for you.

jqPlot

jqPlot is a plotting and charting plugin for the jQuery Javascript framework. jqPlot produces beautiful line, bar and pie charts with many features.

#4 DataTables – And finally, this jQuery plugin (notice a trend?) is awesome for showing data in a table with tons of great features. Really enhances the functionality of the .NET tables or stands alone as a beautiful addition.
DataTables

DataTables is a plug-in for the jQuery JavaScript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, and will add advanced interaction controls to any HTML table.

I know there are a ton more out there but these are my favorites. Leave a comment with your “go-to” JavaScript libraries.

Tim Ferro

NOVA Code Camp 2014

Click for PowerPoint

Visual Studio 2013 for ALM and .NET Development
Saturday 10/11 @ 2:25pm

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 .Net Development. From project planning, to mobile testing, to inline enhancements via CodeLens and Peek, this session will show developers and team leads why Visual Studio 2013 is worth upgrading to immediately!

http://lanyrd.com/2014/nvcc14/sdftbb/

Dog Food Conference 2014

Dog Food Conference 2014

Catch me twice at Dog Food Con 2014 next week! I’ve never been to Ohio before so please come say hi! The conference agenda page is here for more info.

The Evolution of SharePoint Event Receivers from On-Prem to the Cloud
Monday 9/29 @ 11am in the Scarlet and Gray room

Here’s the PowerPoint presentation
Here’s the code on GitHub

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.

Visual Studio 2013 for ALM and .Net Development
Tuesday 9/30 @ 9:50am in the Scarlet and Gray room

Here’s the PowerPoint presentation
Here’s a screencast from April

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 .Net Development. From project planning, to mobile testing, to inline enhancements via CodeLens and Peek, this session will show developers and team leads why Visual Studio 2013 is worth upgrading to immediately!

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
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. (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).

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

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

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

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

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

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

Tim Ferro

SharePoint Saturday DC Chevy Chase 2014

Click image for PowerPoint

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!