4

I have a requirement where I need to track the changes made on page every time it is published on PROD.

I am planning to use PublishInfo of the page and get the timestamp of second last published event.

ArrayOfPublishInfoData info = client.getListPublishInfo(Page.Id);

        for (PublishInfoData infoData : info.getPublishInfoData()) {

            System.out.println(infoData.getPublishedAt());
        }

But above code is returning null against the published date.

After that iterate over the componentpresentation and compare if any particular component is updated after the above timestamp and list it as changes made on the page.

I am using the below event to initiate the business logic:

EventSystem.Subscribe<PublishTransaction, SetPublishStateEventArgs>(InformUsers, EventPhases.TransactionCommitted);

Please let me know if it is a good way or is there any other way to do this?

Thanks

2

Tridion does not store publish information other than the latest publish. You will have to write custom code to capture this information. We had the need to show publish info like who published, when, what version and to which target to users and that's when we found out it is not available out of the box. We wrote event system code using async methods to capture this information.

For your case, you need to do something similar OR alternatively you can capture the package on publish and save the pages xml which will have full rendered xml of the page, which you can use for comparison.

  • Thanks Vipin, but if Tridion doesn't hold history then it would be a problem for me as I can't have the custom DB to hold the values of publish info. But I think this must be a common scenario for other users too to track the changes of any item like page or component. There should be an API or alternate way to do that or maybe if I can use version history of the page, but with version history I found that even if you don't change anything on the page and checkin the page, it creates a new version. – Yash Jun 22 '16 at 17:12
  • As I suggested in my answer, you can capture publish info and then from there you know which version of the page was published where and when. Use those details to do the comparison or indicate to the user to compare version x and y based on publish info and view the differences themselves using history of the page. I know this is not ideal but publish info history isn't captured. The page modification history is captured though and you can compare versions. – Vipin Kothari Jun 22 '16 at 18:07
2

The SetPublishState event is only called after a successful transaction, reference

If you use this event on transactioncommitted, then current publish would have already succeeded and the time from publishinfo will be current date time and you will not find any components modified after that.

There are two approaches that you can try:

  1. Instead of using TransactionCommitted phase, use Initiated phase
  2. Instantiate workflow which will perform the tracking of the changes and ultimately publish the page.

I would recommend approach 2 as it is more clean approach and you will not block the publishing queue while other transactions are performing the tracking activity.

Please note, event system with Async also blocks publishing queue so other items will have to wait.

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.