Search code examples
tridiontridion-2011

How to get the Revisor details?


I am trying to take the Revisor and CheckOutUser user details for the Page. Below is my code

Page page = engine.GetObject(package.GetValue("Page.ID")) as Page;
string revisor = page.Revisor.Description;
string currentuser = page.CheckOutUser.Description;

Currently, the page is updated by the user "A" and user "B" checkedout the page now. But am getting the Revisor and CheckOutUser as "B",but the revisor should be "A"

The "page.Revisor.Description" is considering the checkedout version instead of current version.

How to get the correct revisor details?


Solution

  • The TOM.NET API documentation states the following for the VersionedItem.Revisor Property: Gets a value indicating the user who last modified this (version of this) item.

    So indeed you would be getting the user who checked out the item at this time rather than the user who last modified it before that.

    So if you need to have the previous Revisor, you should open that version of the item, reading it from its history. You can simply use Session.GetObject(TcmUri) where you create a new instance of the TcmUri using the previous version: TcmUri(itemId, itemType, publicationId, version)

    By the way the code example you give is coming from a Template, but you indicate you are using it in a event handler (there is no engine in a event handler). In the Template you would not get this result as that should be using the last checked in version of the item when you Publish it. For Preview you will see the same results as you are now, since that again is working with the current (checked out) version.