2

I've created a custom workflow .As per workflow when it is in final state, the workflow will not kick off unless user create a new version and clicks on edit.

Question:

  1. Is there a way to enable auto version creation on click of Review-Edit?
  2. Also I m looking at option to enforce auto creation irrespective of user role. I want this auto creation should be implied to administrator or any logged in user to cms system.

Any help. Let me know if any clarification required.

  • Do you want the same approach for those items where workflow is not set? Because you can click on this button even the item doesn't have workflow. – Vlad Shpak Dec 14 '16 at 12:12
  • @Santosh Can you explain what is the requirement you are trying to solve. – phani Dec 14 '16 at 13:25
  • When there is workflow associated with an item then on click of edit new version should be created by default. – Santosh Poojari Dec 15 '16 at 2:35
  • Requirement: we have 2 state- Draft and Published. We want CMS author or admin if made any changes must go through this workflow. Now for given version once auto publish is done in Published state any changes after that require a new version. This will not happen unless user creates new version . What we want is? Create new version on review-Edit automatically irrespective of user role. Also version is created through version tab or through cms item itself but in case author goes to review and click on edit tab we want to ensure new version is available by default. Hope i m clear now. – Santosh Poojari Dec 15 '16 at 2:50
  • I also looked this option but it states admin user will not have this option.paragdaraji.wordpress.com/2016/05/18/… – Santosh Poojari Dec 15 '16 at 2:56
1

There is a command "item:checkout".

<command name="item:checkout" type="type=Sitecore.Shell.Framework.Commands.CheckOut,Sitecore.Kernel"/>

Use patch instead to override the command.

<command name="item:checkout" type="Sitecore.Custom.Commands.MyCheckOutCommand, Sitecore.Custom" patch:instead="command[@type='type=Sitecore.Shell.Framework.Commands.CheckOut,Sitecore.Kernel']"/>

Here is a command. Try something the same.

    [Serializable]
public class MyCheckOutCommand : Sitecore.Shell.Framework.Commands.CheckOut
{
    public override void Execute(CommandContext context)
    {
        var item = context.Items[0];
        Database db = item.Database;
        IWorkflow workflow = db.WorkflowProvider.GetWorkflow(item);
        WorkflowState state = workflow.GetState(item);

        if (Sitecore.Context.User.IsInRole("[roleName]") && workflow.WorkflowID == "[WorkflowID]" && state.StateID == "[StateID]")
        {
            item.Versions.AddVersion();
        }
        base.Execute(context);
    }
}
  • @Sanatosh Poojari Tell me result. The example I provided is for the Edit button in the Review ribbon. But also there is Edit button in the Home ribbon. – Vlad Shpak Dec 16 '16 at 9:28
  • @ vlad shpad I'm in the process of creating a proof of concept. Yes i m looking at edit button in the review tab.Also the requirement I got is very much in nascent state. I appreciate your help and direction. Thanks. – Santosh Poojari Dec 18 '16 at 1:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.