Search code examples
permissionsworkflowsitecoresitecore7

Sitecore Workflow Only for Specific User


I have three users (A, B and C) and set workflow for items. The workflow process is perfectly working as I expected.

In this case, I'd like to set workflow only for A user and other users (B and C) will not use any workflow process even the process was already assigned into content items.

So, A user will follow the process like "submit", "approval" and "publish". B and C users will not use workflow and they are not required, just change and publish.

How can I do this??? I guess I need to update workflow permission in security??


Solution

  • You'll have to write some custom code to do this as you can't skip the workflow on an item.

    Instead you can write some code to hook into an event - on save seems like a good option. you can check:

    if the item has workflow

    If the user had a specific role to skip workflow (users b and c)

    If Workflow is in the correct state

    On these conditions you can then programmatically action the workflow to the next state or set the workflow field to approved.

    Some great sample code from Cognifide here on actioning or updating the workflow on an item programmatically

    https://www.cognifide.com/blogs/sitecore/changing-workflow-state-of-sitecore-items-programmatically/

    There's also an example here of somebody setting up a skip approval action to push the items workflow to the final state.

    How to programmatically approve a content item in Sitecore

    I'd advise you to be careful with skipping workflow as content can easily end up being approved accidentally if the power user edits editor's content. It can be annoying for some users to keep pressing submit and approve all the time but it is a good fail safe.

    Another thing you could do is create a custom workflow action after the draft state to update the workflow to the final state when a new item is created in draft by users b and c.