1

When we try to publish any Sitecore item in the draft workflow state then after clicking on publish we get a confirmation box as shown in the image. I need to customize this popup (Edit its text and remove "OKAY" button). Please let me know where to find its code.

Publishing warning for items in Draft workflow state

1 Answer 1

3

You will find the logic of this confirmation box under Sitecore.Kernel DLL. If you extract the DLL, you will find the logic of the confirmation box that is written under the class Sitecore.Shell.Framework.Commands.PublishItem. Under the below method, this is written.

private static bool CheckWorkflow(ClientPipelineArgs args, Item item)
    {
      Assert.ArgumentNotNull((object) args, nameof (args));
      Assert.ArgumentNotNull((object) item, nameof (item));
      if (args.Parameters["workflow"] == "1")
        return true;
      args.Parameters["workflow"] = "1";
      if (args.IsPostBack)
      {
        if (args.Result == "yes")
        {
          args.IsPostBack = false;
          return true;
        }
        args.AbortPipeline();
        return false;
      }
      SiteContext site = Factory.GetSite("publisher");
      if (site != null && !site.EnableWorkflow)
        return true;
      IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
      if (workflowProvider == null || workflowProvider.GetWorkflows().Length == 0)
        return true;
      IWorkflow workflow = workflowProvider.GetWorkflow(item);
      if (workflow == null)
        return true;
      WorkflowState state = workflow.GetState(item);
      if (state == null || state.FinalState)
        return true;
      args.Parameters["workflow"] = "0";
      if (state.PreviewPublishingTargets.Any<string>())
        return true;
      SheerResponse.Confirm(Translate.Text("The current item \"{0}\" is in the workflow state \"{1}\"\nand will not be published.\n\nAre you sure you want to publish?", (object) item.DisplayName, (object) state.DisplayName));
      args.WaitForPostBack();
      return false;
    }

Now What you can do is create your own processor and use yours in the case of the OOTB given below. For this, you need to create a patch.

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

For the whole implementation, you can refer to this blog.

https://blogs.perficient.com/2018/09/21/looking-for-ways-to-customize-warning-messages-in-sitecore-content-editor/

Finally when it uses SheerResponse.Confirm then it will show the confirmation box like it is showing. So if you don't want to show the buttons then you can use SheerResponse.Alert.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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