Sitecore Workflow commands not being shown in the ribbon or gutter.

Requirement

The customer required that when an item is in a a specific workflow state, the item cannot be edited.

Sitecore has a special security permission to achieve this Workflow State Write, if you set this to deny on the relevant workflow item, the item will become readonly whilst in that state. Perfect I thought, of course you have to ensured that the user has the Workflow Command Execute permission.

Problem

Unfortunately in Sitecore 8.1.0.151207, if you do not have write access to the item, the workflow commands are not shown in the ribbon and the workflow gutter icon is not visible either.

Therefore, the user cannot approve or reject the item, unless they are an administrator!

Solution

However, if you want to display workflow commands in the ribbon even if workflow write access is denied you can follow the following steps:

  • Use dotpeak, resharper, etc and decompile Sitecore.Shell.Applications.ContentManager.Panels.WorkflowPanel class.
  • Change the namespace and or the class name.
  • Modify the CanShowCommands method, in my case I checked to see if the current user has the workflow execute permissions.
public static bool CanShowCommands(Item item, WorkflowCommand[] commands)
{
Assert.ArgumentNotNull(item, "item");
if ((item.Appearance.ReadOnly || (commands == null)) || (commands.Length <= 0))
{
return false;
}
if (Context.IsAdministrator ||(item.Access.CanWriteLanguage() && (item.Locking.CanLock() || item.Locking.HasLock())))
return true;

// get command item from 'master' database
Item curItem = item.Database.GetItem(ID.Parse(commands[0].CommandID));
// check if user can execute workflow commands
if (AuthorizationManager.IsAllowed(curItem, AccessRight.WorkflowCommandExecute, Context.User))
return true;
return false;
}
  • Build the assembly and deploy it to the website.
  • Modify the following item in the Core database /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Workflow/WorkflowPanel change the Type field, so it matches your WorkflowPanel class.

I hope this helps, and yes I know it is not nice, but until this bug is fixed it was the best that I could do.

4 thoughts on “Sitecore Workflow commands not being shown in the ribbon or gutter.

  1. jitendrasonisite

    This is good Alan, As we can handle this through the Access management, I guess that should be the preferred input

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s