4

Is is possible to perform autopublish of item on intermediate, not final state of sitecore workflow?

Sitecore 9.0.1, Admin user.
I have custom workflow with the following states:

  1. Editing
    • Submit
  2. Reviewing
    • Approve (autopublish item to web database)
      • Auto Publish Action
    • Reject (move item to Editing)
  3. Published
    • Approve (autopublish item to production database)
      • Auto Publish Action
    • Reject (move item to Editing)
  4. On Production (final state)

When item goes from Reviewing -> Published state (by approval) - it's not being autopublished. It works only from Published -> On Production.
I've tried to achieve this by Sitecore.Workflows.Simple.PublishAction

workflow

I also tried to wrote custom processor for this and do publish via code:

PublishManager.PublishItem(dataItem, targets, master, isDeep, false, publishRelated);  

or

var po = new PublishOptions(master,
                           targetDb,
                           PublishMode.SingleItem,
                           lang,
                           System.DateTime.Now);
po.RootItem = dataItem;

Publisher publisher = new Publisher(po);
publisher.Publish();

Code executes, but nothing publishes, no errors in logs.

Is it even possible?

2
  • Sitecore never publishes item which is not in a final workflow state. In your scenario this would mean both Published and On Production states would have to be final states. You may try that but I have no idea if this will work for you.
    – Marek Musielak
    Feb 11, 2019 at 13:51
  • 2
    Btw cross posting is not recommended. I suggest you remove one of your questions stackoverflow.com/questions/54598352/…
    – Marek Musielak
    Feb 11, 2019 at 13:52

1 Answer 1

4

The piece you're missing is that on that intermediate workflow state (Reviewing, in your example) you need to set the Preview publishing targets field:

Preview publishing targets field

Check your web target in that field for your Reviewing state and the auto-publish action should work as expected.

Note: if your target does not show up in this list, you may need to navigate to the publishing targets (/sitecore/system/publishing targets) and check the Preview publishing target checkbox:

Preview publishing target field

2
  • Now it works, thank you! But it works only when I use Sitecore.Publishing.Publisher. If I use Sitecore.Publishing.PublishManager the item is skipped and not being published. Currently, I don't know the reason of this. Feb 11, 2019 at 14:16
  • PublishManager works with the below code.. Sitecore.Data.Items.Item item = Sitecore.Configuration.Factory.GetDatabase("master").GetItem("/sitecore/content/Home"); Sitecore.Publishing.PublishOptions opt = new Sitecore.Publishing.PublishOptions(Sitecore.Configuration.Factory.GetDatabase("master"), Sitecore.Configuration.Factory.GetDatabase("web"), Sitecore.Publishing.PublishMode.SingleItem, item.Language, DateTime.Now); opt.RootItem = item; Sitecore.Publishing.PublishManager.Publish(new Sitecore.Publishing.PublishOptions[] { opt }); Feb 11, 2019 at 15:09

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.