7

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

 3 years ago
source link: https://blog.coates.dk/2017/03/13/sitecore-workflow-commands-not-being-shown-in-the-ribbon-or-gutter/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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.

missing.png?w=625&h=211

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK