Thursday, 28 July 2016

New Document Library Experience : Part II Custom Actions

In my pervious post I explained the newly introduced experience with a deep dive explaining the various building blocks of the page. In this post, I will focus more on one particular action which is  the custom action, and how it has been affected by the new experience.

Custom Action Navigation Action

Custom actions are handled using "odsp-next/actions/odb/CustomActionNavigationAction" module. In this module, a simple check to UrlAction property value is done. The decision is solely based on whether it starts with the string "javasctipt:"  or not . In the first case, a call to executeCustomActionJSCode function will be performed. However, in the second case(when you simply register UrlAction as a simple link) new window will open and navigate to the desired web address.

Note:When you register your custom action using visual studio , the custom action ActionUrl property will be converted to Javascript:LunchApp(yourUrl,popup options)

popup options will always be null unless you use dialog width and height parameters in the custom action definition in Visual Studio elements.xml File. If the popup options parameter is not null, a  Javascript error will be thrown. To reproduce this simply try any custom action with dialog parameters , deploy it to SharePoint library as ECB or ribbon button.

Before execute javascript code block window.RegisterSod is called for alot of SharePoint files which used to be included/registered via masterpage

Any ScriptLink Globally registered script is no longer executed in the new experience pages like document library/site contents.

Url Token Replacement

Another important notice that not all the tokens within the ActionUrl will be replaced, only the following token will be replaced if you are using the new SharePoint library experience.
  1. {ItemId}
  2. {ListId}
  3. {Source}
  4. {SiteUrl}
  5. {ItemUrl}
  6. {SelectedItemId}
  7. {ListUrlDir} 

What to expect next:

Currently all the customization opens the classical SharePoint dialog doesn't work in the new document library experience, it will be nice if Microsoft release the new extensibility framework which will eventually replace the old dialog with the ability to create your own action handlers,components and executors similar to rename out of the box actions:



Related Articles