Question

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?

Was it helpful?

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.

OTHER TIPS

It is working as you expect if you are reading checked in version of page (i.e. your ID is "tcm:xx-xx-64"). Hovewer if you are reading dynamic version (that is checked out version - "tcm:xx-xx-64-v0") you will get situation when Revisor and CheckOutUser are the same. The reason for this is that the dynamic version of your page is not the same as checked in version. Dynamic version is only temporary object where all the actions were done by user who checked out the item, so Revisor and CheckOutUser for this version of page is the user who checked it out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top