9

I have some familiarity using Core Services. I am wondering if I can use this (or another feature) to batch a publishing routine.

I frequently publish 2 pages from 2 different sites and I find it tedious to fill out the publish screen every time. I am also publishing child items.

In a perfect world, I'd like to make my component changes and then hit a single click on my batch job or LINQPad application to execute the publishing routine.

13

Yes - the core service supports publishing. Have a look at:

ICoreService2011.Publish

you can call it with the following signature:

IEnumerable<PublishTransactionData> Publish(
    IEnumerable<string> ids,
    PublishInstructionData publishInstruction,
    IEnumerable<string> targets,
    Nullable<PublishPriority> priority,
    ReadOptions readOptions
)
9

First Approach- You can achieve it through event system and it is recommended to perform such auto publishing along with integrated workflow so that the content can be verified before publishing. In Tridion 2009 Event System there is an event trigger named “OnActivityInstanceFinishPost” and also sure about something equivalent in Tridion 2011. We generally put a check ‘is this last activity instance in the flow’ if yes , issue a publish instruction . The input parameter into this event is the ActivityInstance that just finished.

Second Approach - You can write a script with powershell or .net which calls the publish action using TOM via Interop. Since you are using Tridion 2011 I would like to recommend you to achieve this through Core Service rather than TOM.

Third Approach- It is simplest and safer, you can create a custom page to publish the pages inside a structure group of a publication.

Forth Approach- Power tool releases for Tridion 2009 have page publisher functionality. You can check similar functionality in power tool for Tridion 2011.

7

As was mentioned already, yes you can publish using the Core Service, and it is pretty straightforward:

RenderInstructionData renderInstruction = new RenderInstructionData();
ResolveInstructionData resolveInstruction = new ResolveInstructionData();

PublishInstructionData publishInstruction = new PublishInstructionData
                                                {
                                                    DeployAt = DateTime.Now,
                                                    MaximumNumberOfRenderFailures = 0,
                                                    RenderInstruction = renderInstruction,
                                                    ResolveInstruction = resolveInstruction,
                                                    StartAt = DateTime.Now
                                                };
_client.PublishAsync(itemIds, publishInstruction, new[] {targetId}, PublishPriority.Normal, null);

Since you mention LinqPad, you may want to check Frank van Puffelen's Tridion Driver for LinqPad.

2

Multiple ways to achieve this:

1) Create an Event System for Component Save, as soon as you saved the component, you can write code in C# to automatically publish desired pages. - This will even save on clicking the batch job

2) Create a Job using Core Service to publish the desired component and invoke the job through event system on Component Save - Saved an additional Effort

3) Create a Job using Core Service to publish desired component and trigger it manually.

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.