7

I have created an event system which creates a page when a component is created, and publishes that page. I want to publish it from the publication where the page is created, with the IncludeChildPublications setting set to true. I have 18 child publications, and I have verified that publishing works for all of them.

This is my code:

RenderInstruction renderInstruction = new RenderInstruction(component.Session) { RenderMode = RenderMode.Publish };
ResolveInstruction resolveInstruction = new ResolveInstruction(component.Session) { IncludeChildPublications = true, OnlyPublishedItems = false };
PublishInstruction publishInstruction = new PublishInstruction(component.Session) { ResolveInstruction = resolveInstruction, RenderInstruction = renderInstruction };
PublishEngine.Publish(new[] { page }, publishInstruction, new[] { "Staging" });

Note that I publish to the PublishPurpose 'Staging', which is - I guess - the way to go with SDL Web 8. I don't use the legacy mode so the overloads of the Publish method that use PublishingTargets or TargetTypes are presumably not working.

What I find is that the page gets published for one of my child publications, but not for the other 17. When I go to the GUI and publish the page manually (with the 'publish in child publications' setting turned on), the page gets published for all 18 child publications. Clearly something is wrong in the event system.

The Windows event log shows the following warnings when the event system tried to publish the page in all child publications:

No Publish Transactions created for (un-)publish action for Publication 'tcm:0-37-1'. Reason: unable to resolve Target Types for purposes: Staging.

There is one warning for each of the 17 child publications where the item fails to publish.

What's going on here? Should I change my code for publishing the page? Why does it work for this 1 page?

  • 1
    Update: I found out you can still use target types even if you don't have legacy publishing enabled. That fixes the problem for me. However, I would still like to know why publishing to the PublishPurpose does not work correctly. – Quirijn Aug 24 '16 at 11:42
  • 1
    If you specify publish purpose, CM will do an extra step and resolves it into Target Type. For this, two pieces of puzzle required: (1) mapping with current publicationId and purpose in Topology Manager and (2) Business Process Type that is associated with current publication should have a target type with "Staging" purpose. When you specified target type directly, you skipped this resolving part. Make sure that mappings for all publications exist and BPT with Staging target type is associated with each publication. Also note that purpose is case-sensitive. – AntonM Aug 26 '16 at 6:50
  • Mappings exist, and the BPT is created once in a master publication, and inherited by all child publications. How can I associate the BPT with each publication then? – Quirijn Aug 26 '16 at 13:41
  • 1
    It's in the properties of the publication: in UI or API (Repository.BusinessProcessType). If you created BusineesProcessType in parent publication after child publication was created, then this property will not be propagated automatically to all children. Check the properties of child publications and if BusinessProcessType is empty there, set it to shared BPT. – AntonM Aug 27 '16 at 18:54
  • That wasn't the case, the BPT was present in the properties of all publications. – Quirijn Aug 31 '16 at 9:02
1

It's in the properties of the publication: in UI or API (Repository.BusinessProcessType). If you created BusineesProcessType in parent publication after child publication was created, then this property will not be propagated automatically to all children. Check the properties of child publications and if BusinessProcessType is empty there, set it to shared BPT.

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.