I need to fetch those TCM IDs from publishing queue which has been unpublished successfully using Tridion Core Service.
1 Answer
You will have to use PublishTransactionsFilterData
filter to retrieve all publish transactions based on your criteria.
PublishTransactionsFilterData ptfd = new PublishTransactionsFilterData()
{
PublicationTarget = new LinkToPublicationTargetData() { IdRef = "tcm:0-19-65537" },
ForRepository = new LinkToRepositoryData() { IdRef = "tcm:0-127-1" },
PublishTransactionState = PublishTransactionState.Success
};
IdentifiableObjectData[] transactions = CoreServiceConnector.Client.GetSystemWideList(ptfd);
However, this filter has no info on resolve purpose, so you will have to read each transaction, get its ResolveInstruction.Purpose
and check if its ResolvePurpose.UnPublish
:
foreach (PublishTransactionData transaction in transactions)
{
PublishTransactionData transactionData = (PublishTransactionData)CoreServiceConnector.Client.Read(transaction.Id, new ReadOptions());
if (transactionData.Instruction.ResolveInstruction.Purpose == ResolvePurpose.UnPublish)
{
// do something
}
}
Just an update, you have to read every transaction again with client.read because ResolveInstruction
is not available on GetSystemWideList()
because of lazy load.
-
Note that the Publish Queue in CME also shows Publish or Unpublish, so that info is available in the list data. I don’t have a system at hand to check which property it is, but I expect a
PublishTransactionData
property to reflect Publish/Unpublish in the list data (no need for full loads). Nov 30, 2018 at 10:14 -
its shown as Action="1" for Unpublish, Action="0" for publish, or Action="2" for republish, and min value of integer for uknown by client if XML is retrieved instead of objects.– Marko Milic ♦Nov 30, 2018 at 10:18
-
So yeah, LINQ can be used to filter based on XML property if GetSystemWideListXml() is used.– Marko Milic ♦Nov 30, 2018 at 10:19
-
Thanks @MarkoMilic, the reference code and instruction is really very helpful. my issue has been resolved by following your resolution steps.– User 45Nov 30, 2018 at 12:10
PublishTransactionData
object should contain details about the Publish Instruction.