Open commands in workbox

Open experience editor from workbox

It seems like an easy task to relink the workbox items open command so that they instead of open the page editor open the experience editor. It does however demand some special treatment.

Undesired workbox functionality

In the workbox there a are two links that open the item that needs to be handled. The problem is that it opens the item in the content editor. Not many editors should work in the content editor and some editors do not even know that the content editor exists.

Open commands in workbox

What do the workbox links do?

The workbox is defined in the folder siteroot/sitecore/shell/Applications/Workbox. In that folder the file Workbox.xml can be found, it looks like this:

<?xml version="1.0" encoding="utf-8" ?> 
<control xmlns:def="Definition" xmlns="">
    <Favicon Src="/sitecore/images/favicon.ico" runat="server" />
    <CodeBeside Type="Sitecore.Shell.Applications.Workbox.WorkboxForm,Sitecore.Client"/>
    <Stylesheet Src="Content Manager.css" DeviceDependant="true"/>
    <Stylesheet Src="Ribbon.css" DeviceDependant="true"/>
    <Stylesheet Src="Workbox.css" DeviceDependant="true"/>
    <Stylesheet Src="/sitecore/shell/themes/navigator.css"/>
    <Script Src="/sitecore/shell/Applications/Content Manager/Content Editor.js"/>
    <Stylesheet Key="Workbox">
      html { width:100%; height:100% }
      body { width:100%; height:100%; overflow:auto }
      #States table { width: 100%; }
    <FormPage Application="Workbox" Title="Workbox">
      <input type="hidden" id="scActiveRibbonStrip" name="scActiveRibbonStrip" />
      <Border ID="Grid">
        <Border ID="RibbonPanel"/>
        <Border Class="scGreyBackground scStretchAbsolute scWorkboxContentContainer">
          <Border ID="Grid2">          
            <Border ID="States">

The interesting line here is Sitecore.Shell.Applications.Workbox.WorkboxForm. That is the codefile for this xml. In that file we find among other things a definition for Open() that in the end runs this line.

Windows.RunApplication("Content editor", urlString.ToString());

That line opens the content editor (obviously). So the task is to change that.

Create a new Workbox.xml

In order to override the standard functionality, the codefile needs to change. This can be achieved by simply changing the Workbox.xml and replacing the line Sitecore.Shell.Applications.Workbox.WorkboxForm,Sitecore.Client with the modified codefile location will do the trick. Something like Foundation.SitecoreModifications.Shell.Applications.Workbox.CustomWorkboxForm,Foundation.SitecoreModifications will instead call the CustomWorkboxForm.

Override the original WorkboxForm

A new class that is called CustomWorkboxForm needs to be created and that should inherit from the original WorkboxForm. And in the Open() method the Execute command in the OpenExperienceEditor class needs to get called. The rest is just Asserts for null values and setting the necessary variables.

    public class CustomWorkboxForm : WorkboxForm
        protected new void Open(string id, string language, string version)
            Assert.ArgumentNotNull(id, nameof(id));
            Assert.ArgumentNotNull(language, nameof(language));
            Assert.ArgumentNotNull(version, nameof(version));
            Language.TryParse(language, out var lang);
            Assert.ArgumentNotNull(lang, nameof(lang));
            Sitecore.Data.Version.TryParse(version, out var ver);
            Assert.ArgumentNotNull(ver, nameof(ver));
            Item item = DatabaseRepository.GetActiveDatabase().GetItem(new ID(id), lang, ver);
            Assert.ArgumentNotNull(item, nameof(item));

            var openExperienceEditorCommand = new OpenExperienceEditor();
            CommandContext context = new CommandContext(item);

This is the only solution I found. If you know a better one that does not involve applying violence to the sitecore shell applications please let me know in the comments below. Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *