Search code examples
tridiontridion-2011

How to unpublish published pages in Tridion using core services?


I have some pages created in a structure group in one publication. I want to unpublish all those published pages using core services. Can anyone help me out?


Solution

  • You can use the .UnPublish method of the CoreService client, passing it the URI of the StructureGroup you wish to unpublish the Pages from. This is what the CoreService API reference (well worth a read...) says:

    Un-publishes the collection of IdentifiableObjectData instances from given target(s).

    IEnumerable<PublishTransactionData> UnPublish(
        IEnumerable<string> ids,
        UnPublishInstructionData unPublishInstruction,
        IEnumerable<string> targets,
        Nullable<PublishPriority> priority,
        ReadOptions readOptions
    )
    

    Parameters

    ids
    Type: System.Collections.Generic.IEnumerable<String>
    Collection of identifiers of the items to unpublish (TCM URI or WebDav URL).

    unPublishInstruction
    Type: Tridion.ContentManager.Data.Publishing.UnPublishInstructionData
    The instruction for the un-publish action.

    targets
    Type: System.Collections.Generic.IEnumerable<String>
    A collection of target identifiers representing Publication Targets or Target Types to un-publish from. This cannot contain a combination of both.

    priority
    Type: System.Nullable<PublishPriority>
    The priority of the un-publish action. Passing null will use the priority from the Publication Target.

    readOptions
    Type: Tridion.ContentManager.CoreService.ReadOptions
    Specifies how the Publish Transaction(s) are read back after un-publishing. If the parameter is null, the items are read with None.

    Return Value
    A collection of PublishTransactionData