Showing posts with label Custom Actions. Show all posts
Showing posts with label Custom Actions. Show all posts

Wednesday 1 November 2017

Using a CDN for Custom User Actions

Problem:  I need to inject JavaScript into a couple of hundred thousand site collections and subsites using a Custom User Action.  I want to use a CDN.  Governance will not let me add to the layouts folder on the WFE's.  Using a CDN for a CUA is causing the blank page.

Initial Hypothesis:  I don't want to deploy the same JS file hundreds of thousands of times into the local site collections.  As updating and storage are crazy.  I want a CDN like behaviour, and the closest I can get is to modify the hive directory on each SharePoint on-prem. farm that allows me to reference the JS.  I do have several farms and IT governance won't let me modify the WFE's.

Tobias Lekman has an excellent comprehensive overview of the CUA issue:
https://blog.lekman.com/2013/01/scriptlink-registration-in-sharepoint.html

Doing the usual testing, bizarrely I can use anonymous https://radimaging.sharepoint.com/_layouts/15/guestaccess.aspx?docid=55529eccf4555d698555cb26108fb555&authkey=555-6M9555zF555g555 for my CUA JS file.
When I allow external access on my personal public O365 E3 tenant, I can use this URL, the CUA works perfectly.  My client does not have an Office 365 external public tenant I can use, so an Akamai (or another CDN)CDN and fake the validation.  It's either SP URL validated, or I need to load it differently if I want to use a CDN.  I used an Akamai CDN and added /_layouts/15/ into the URL using folders, and the CDN started working for my CUA. e.g. https://cdn.domain.com/sharepoint/_layouts/15/cuatest.js

Possible Resolution:
  1. Local Site Collection uploaded files
  2. CDN assuming the JS location has: 

Sunday 10 September 2017

Custom User Actions: Injecting JavaScript

Problem: Changing Master pages is not good for support and can cause your applications to break when updates are done.

Possible Resolution:  Inject JavaScript to perform custom logic and branding using Custom User Actions.  This allows you to inject JavaScript at the appropriate level and not change any OOTB pages or user controls.  Custom User actions can be applied at 3 levels in a Site collection namely at:
  1. Site Collection Level (always fired),
  2. SPWeb Level or at the
  3. List (Document library) level.
More Information:
Tool to try and add Custom User Action looks useful:
https://spusercustomactionmanageronline.codeplex.com/
https://msdn.microsoft.com/en-us/pnp_articles/customize-your-sharepoint-site-ui-by-using-javascript

Tuesday 7 December 2010

Amending the Welcome Menu

Problem: Welcome Menu or Personal Actions Menu occasionaly refered to as the User Menu. SharePoint 2010 that displays the users name in the Welcome server control, this by default in the top right of the master page.  You can add new menu items or hide existing menu items.
Initial Hypothesis
  • The Welcome user control is located in the 14 hive at 14\TEMPLATE\CONTROLTEMPLATES

  • The user control is reference in master pages.
  • Take a copy of the welcome.ascx file as you will be working on the original or need to reference your new copy in your master page.
Resolution: Hide the menu option in the Welcome Menu.
Use the PermissionString property to dispay the menu option depending on your permissions.
Edit the Welcome.ascx file for each menu option element add the visible attribute and set it to false to hide the menus.
List of valid properties for the PermissionsString property
Alternatively set the MenuItemTemplate attrivute visibility to false, this will hide the menu option for everyone.
 
Resolution - Another option for changing the welcome control:
  • Remove the server control wssuc:Welcome from the master page or set it's visibility to hidden.
  • Then write a Replacement control and add it to the master page.

 Resolution:  Add a new menu item
  • Add a new element to the project that will be deployed as a feature

  • Add the following code to the element file

 

  •  New menu item (Open BBC) is add to the welcome menu.

 

More Info:
http://glorix.blogspot.com/2007/08/custom-action-locations-and-groupid.html
http://www.sharepointnutsandbolts.com/2007/07/using-customaction-to-modify-system.html
http://blog.thekid.me.uk/archive/2007/06/23/sample-editcontrolblock-customaction-for-sharepoint.aspx

How to Hide Ribbon
http://blogs.msdn.com/b/zwsong/archive/2010/04/29/how-to-hide-ribbon-from-users-without-edit-page-privilege.aspx

Chris O'Briens Ribbon Customisation blog series
http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html