3

I want to check for pages that are unpublished for longer than a month, but still available in Tridion. Is there a possibility to check the last UNPUBLISHED date via the Core Service?

I already had a look at the 'PublishInfoData' object and the 'ListBaseColumns.Extended'.

  • PublishInfoData - only used to get the all publish info, not for unpublished info, as long as if the publishing queue was not deleted you can able to query the publishing queue to get the unpublished info – Velmurugan Jan 22 '18 at 14:14
5

With 100% certainty I would say no, because as far as I know that information is not stored in Tridion, only the last Publish date is. That information is held in the PublishedAt property in the (as you've already mentioned) PublishInfoData class retrieved via the GetListPublishInfo method. The GetListPublishInfo is equivalent to the GUI actions of clicking Where Used and viewing the Published to tab.

But ... as @velmurugan has already mentioned, you can read it from the publishing queue if the respective transaction hasn't been deleted yet. To do that you can use the PublishTransactionsFilterData with the appropriate properties set, in conjunction with the GetSystemWideListXml or GetSystemWideList methods.

To capture the unpublish dates without relying on the Publishing Queue, you would have to create an Event handler which would persist the data to somewhere. The most appropriate EventArgs would be the SetPublishStateEventArgs in combination with checking the publish action (publish/unpublish). That event is only triggered on successful (un)publish actions.

1

One way, (other than Event System, etc) to do this would be to get a list of Publish Transactions and then iterate through them to get the the item(s) that your interested in and check that the transaction is an unpublish action.

The following code may help as a starter:

PublishTransactionsFilterData transactionFilter = new PublishTransactionsFilterData
    {
        StartDate = new DateTime(2017, 12, 22, 00, 00, 00),
        EndDate = new DateTime(2018, 01, 22, 20, 00, 00),
        PublishTransactionState = PublishTransactionState.Success,
    };

var returnedTransactions = Client.GetSystemWideList(transactionFilter);
foreach (var transaction in returnedTransactions)
{
    PublishTransactionData tx = (PublishTransactionData)transaction; 
    if (tx.ListInfo.PublishAction == 1) . //Check that it's an unpublish action. Publish=0. Unpublish=1.
    {
        //You can then check whether the tx.Items array contains the TcmId of the item you're interested in
        bool containsTcmId = tx.Items.Any(i => String.Equals(i.IdRef, "tcm:0-1234-64", StringComparison.CurrentCulture));
    }
}

As Velu says though, this will not work if the Publish Transaction has been deleted. Also, any subsequent unpublish (or publish) of the item will remove the earlier Publish Transactions relating to it.

  • Hi Jonathan, thank you for the example! Velmurugan and Atila already told me this is the only way to achieve the data I want. – Peter van der Lugt Jan 22 '18 at 14:58
  • You're right, Velu & Atila's approach looks simpler. I'll leave this here in case it helps someone with a similar problem in future (e.g. someone who needs to search over a number of items at the same time). – Jonathan Williams Jan 22 '18 at 15:02
  • Great! ps. the tx.ListInfo needs a casts to PublishTransactionListInfo before you can request the PublishAction. – Peter van der Lugt Jan 23 '18 at 8:10

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.