0

I am trying to display the warning message in the Tridion Message bar when the page or component is checkedout.

I have subscribed and tried with (Processed and Initiated) Phase and tried to Subscribe and SubscribeAynsc.

subscribor line below:

EventSystem.Subscribe<VersionedItem, CheckOutEventArgs>(displaymessage, EventPhases.Processed);

Function below:

public override void displaymessage(VersionedItem item, TcmEventArgs args, EventPhases phase)
    {
        if (item.GetType().Name == "Component" || item.GetType().Name == "Page")
        {
            string chkuser = "aa"               ;
            sting revisor = "bb"
            if(chkuser  != revisor
               {
                   throw new Exception("Warning-->some one is already modified this item and u are checking out now");
               }

        }
    }

I would like to display the warning message if the checkout user and revisor is different. I will take the checkout user and revisor details shortly and will compare.

Issues:

  1. The abaove code display the message in the Tridion message bar, when i select any item and click the "Check Out". at the same time, the item is not in edit mode, it is in read only mode.
  2. When i select any item and clik "Open" or double click the item, checkout event is triggered but the message is not displayed in the Message bar. and still the item is read only mode.
  3. And if i used try{}Catch{} inside my code, when the line "throw new exception" reached, the code is automatically goest to catch block. and mesaage is not displayed even in the "1st (Issues:1)" situation.

Can any one give some insight on this? that would be great!!

Jey
  • 2,137
  • 4
  • 22
  • 40
  • 1
    First of all: what are you trying to achieve? Second: which event are you handling? Can you share the EventSystem.Subscribe line as well? – Quirijn Sep 13 '12 at 10:42
  • Hi Quirijn, Please take a look on the update Question. I have subscribed CheckOutEvent, and i would like to display the warning message if the checkout user and revisor is differernt and allowing the user to checkout the item. – Jey Sep 13 '12 at 10:53
  • If you want it to NOT happen, then why not do it when checkout is initiated rather than when it's finished? – Nuno Linhares Sep 13 '12 at 13:57
  • I dont think we can take the Checkout user details from the initiated phase. – Jey Sep 13 '12 at 13:59

1 Answers1

1

When you trow an exception before the transaction is committed it is rolled back. If this is going to work you need to perform your logic on the TransactionCommitted phase.

But more importantly I would advice not to abuse exception messages to give a status messages. What are you trying to achieve?

Arjen Stobbe
  • 1,684
  • 9
  • 15
  • Hi Arjen, thanks: i would like to display the warning message if the checkout user and revisor is differernt and allowing the user to checkout the item – Jey Sep 13 '12 at 11:18
  • 1
    Maybe a Content Manager Explorer extension is a better approach? But I don't have experience with those. – Arjen Stobbe Sep 13 '12 at 12:00
  • Have you done similar kind in CME? if so can you give some idea on this? – Jey Sep 13 '12 at 12:35
  • 1
    `$messages.registerWarning("This item is checked out by user 'abc'");` – Frank van Puffelen Sep 13 '12 at 14:03
  • Frank, i want to compare between checkkout user and revisior , if both are different, then i want to display warning message and allow the user to checkout the item. – Jey Sep 13 '12 at 14:10
  • Frank: When i place your code in the java script console, this is displaying as Warning message, this is what really i need. but i am trying to do this in Event handler. But your code is Java Script code. how to do this functionality in Java Script? can you give some insight on this? – Jey Sep 13 '12 at 14:28
  • Hi Frank: You mean, do i need to have my extension for the "CheckOut" command from there i have to display the warning message? if so, will it affect the normal CheckOut option/message? and more over, i need to take some details like checkout user and revisor and companre these 2. do i need to do all these in JS? – Jey Sep 14 '12 at 06:33