3

I have a business requirement like I need to provide a custom page to the content author super group so that they can handle check-in or undo check-out of Tridion items checked out by other users.

I have created a LockManagement user group in tridion and added couple of content author super users in it. I provided custom page access to this LockManagement group, where they can enter Tcm Id of the locked Tridion item and can perform undo checkout or check-in.

CoreService will perform actual check-in or undocheck-out using admin user. My problem here is in the case of checkin, it will be recorded on admin user and we can see the same in version history. But i want to track the actual lock management user time stamp and want to see that when I check the history of Tridion item, So that in future while tracking issues we can identify the actual lock manager who checked-in that component.

Even though coreservice does check-in with admin user, I am trying to track the original user with some check-in comment like below, I know below code can’t help to add my checkin comment to the version history visible in GUI, but i am looking for any other similar directions here.

CM Version is : SDL Web 8 (build 8.1.0)

var loggedInUserName = HttpContext.Current.User.Identity.Name;
var checkInComment = string.Format("Checked-in by Lock Supervisor {0}", loggedInUserName);
    .....
    client.CheckIn(itemId, removePermanentLock: true, userComment: checkInComment, readBackOptions: _ReadOption);

version history

1
  • 1
    Please editor your question to update the version of the CM?
    – Velmurugan
    Commented Mar 21, 2018 at 9:01

3 Answers 3

5

Your question isn't completely clear, but I will try and answer the best I can...

I don't understand, which user do you want to track, the one who is doing the checking-in? If yes, you can always get the currently logged in user with the following two snippets:

string user = HttpContext.Current.User.Identity.Name;
//or string user = global::Tridion.Web.UI.Core.Utils.GetUserName();

Do note that for the second you need Tridion's web ui dll. Once you have the username you can use the UsersFilterData filter to eventually retrieve the UserData and get whatever you need.

To see the history of an item you can use the following method + filter:

XElement itemVersions = client.GetListXml(itemID, new VersionsFilterData());

This will give you an XElement with the actual item version + one for each of the major versions which have the same ID but have appended a "-vX" where X represents the version number. You can read the older versions of the item by specifying the "versioned Tcm Uri". This way you have full access to the item's history. For example:

ComponentData componentData = (ComponentData)client.Read("tcm:10-1234-v5", null);

Then you can get the comments by using the following code:

FullVersionInfo fullVersionInfo = componentData.VersionInfo;
string systemComment = fullVersionInfo.SystemComment;
string userComment = fullVersionInfo.UserComment;

But, do note that this only works for major versions. You cannot read minor versions this way, but they will become major versions once checked in.

And finally an FYI, Web 8.5 introduced collaboration Worfklows where multiple users can see the minor versions, not just the owner.

1
1

@Atila already answered most of the API Details for getting version history comment details.

As I understand you are doing custom power page for check in / check out the others checked-out items, alternatively you can use this GUI Extention very specific groups can be configured to see that content menu to AdminCheckIn with specific admin privilege impersonate user using Tridion Coreservice works for Tridion 2013sp1.

0

If you undo checkout then there's no opportunity to update anything in the component - the "history" simply doesn't exist.

As you're checking in using an admin (impersonation) user you have a couple of options but beware the caveats

  1. You could append something to a {metadata} field - but beware if you have workflow enabled (or may in the future)
  2. You could write something to a custom audit data store - update your custom page to provide this historical/tracking data
  3. You could write something to the item App Data to log specific actions such as force-check-in, force-undo-checkout etc.

IMHO Depending on your environment/infrastructure access etc. the database option may be a nice one as it would be easier to extend in the future and easier to tailor to your specific reporting requirements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.