Change the PublishState of an Item

April 4th, 2018 | Posted by Robert Curlette in Tridion | Tridion Core Service

Currently as part of the Publish process, in a post-build event I am sending JSON to an external search engine.  As part of that process, I wait for a response from the search engine that the content arrived successfully.

However, when it doesn’t arrive, I wold like to notify authors via the PublishQueue status that it didn’t get there.  One solution is to update the Publish Status on the published item, setting it to Warning or Failed, and also update the text in the Publish Transaction.  The code below shows how we can do this.  I implemented it as a WebService, so it is possible to be called from any external system, including the event system.

 public void Get(string transactionUri)
 {
      string uri = "tcm:" + transactionUri;
      string binding = "netTcp_201501";
      SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient(binding);
      PublishTransactionData trans = client.Read(uri, new ReadOptions()) as PublishTransactionData;
      string title = trans.Title;
      trans.State = PublishTransactionState.Warning;
      trans.Information = "Didn't make it to Search Index - please publish again";
      client.Update(trans, new ReadOptions());
 }

 

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

Your email address will not be published. Required fields are marked *