3

I have a really strange problem. I have a Sitecore 8.2 site that has preview and web publishing targets. I expect that when a user Submits an item through Workflow, when it is in Awaiting Approval Status, it is published to preview only. However, it is publishing to both preview and web! If I publish items manually and select the publishing target, publishing works as expected.

Here is what I have done so far to no avail:

Checked the box for "Preview publishing target" on the Preview Publish Target item (as described in the Sitecore Documentation) Preview Publishing Target Settings

Checked the box for the preview publishing target on the Awaiting Approval Workflow State (as described in the Sitecore Documentation) Awaiting Approval Workflow State Settings

Contacted Sitecore Support, they instructed me to do the following (which is not stated in the Sitecore Documentation). Doing this caused the issue where publishing to preview would also publish items in Awaiting Approval status to web.

  1. Navigate to "/sitecore/system/Workflows/JHM Health Standard Workflow/Awaiting Approval" item
  2. Right click "Insert" -> "insert from template"
  3. Select "templates/System/Workflow/Action" template and provide appropriate name for item (Auto Publish to Preview)
  4. In the "Type String" field, set the value to : "Sitecore.Workflows.Simple.PublishAction, Sitecore.Kernel"
  5. In the "Parameters" field, set the value to : "deep=1&smart=1"

Any ideas on what I am missing here? Your help is much appreciated!

  • 2
    can you please try by adding targets=preview in your publish action parameter? – Mahendra Shekhawat Sep 5 '19 at 17:29
  • Thank you, that did it! – Shelley Benhoff Sep 6 '19 at 16:17
1

OOTB Auto publish in the workflow is design for the final workflow state, code within is it will always pick the all the database under /sitecore/system/publishing targets if we have not defined the targets in parameter -

 private IEnumerable<Database> GetTargets(
  NameValueCollection parameters,
  Item actionItem,
  Item dataItem)
{
  using (new SecurityDisabler())
  {
    IEnumerable<string> source = this.GetEnumerableValue("targets", parameters, actionItem);
    if (!source.Any<string>())
    {
      Item obj = dataItem.Database.Items["/sitecore/system/publishing targets"];
      if (obj != null)
        source = obj.Children.Select<Item, string>((Func<Item, string>) (child => child["Target database"])).Where<string>((Func<string, bool>) (dbName => !string.IsNullOrEmpty(dbName)));
    }
    foreach (string str in source)
    {
      string databaseName = str;
      Database database = Factory.GetDatabase(databaseName, false);
      if (database != null)
        yield return database;
      else
        Log.Warn("Unknown database in PublishAction: " + databaseName, (object) this);
      databaseName = (string) null;
    }
  }
}

if you want to do an auto-publish on a specific database either you need to pass the targets or need to create your custom auto-publish just to pick all the database you need in non-final state of the workflow. In your case parameter will be like -

"deep=1&smart=1&targets=preview"
| improve this answer | |

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.