I wrote a GUI extension for the SDL Tridion 2011 SP1. The GUI consists of an additional ribbon button and an event handler that runs when the component is saved.
My event handler is registered as follows:
PowerTools.Commands.ItemCommenting.prototype._execute = function (selection) { var item = $display.getItem(); $evt.addEventHandler(item, "save", this.getDelegate(this._onItemSaved)); $cme.getCommand("SaveClose")._execute(selection); };
and the event handler is as follows:
PowerTools.Commands.ItemCommenting.prototype._onItemSaved = function (eventitem) { var comment = prompt("Please enter a comment", ""); $messages.registerNotification("Saving user comments..."); var commentitemid = eventitem.source.getId(); var commenterid = eventitem.source.getCreatorId(); var commenter = $tcm.getItem(commenterid); var commentername = commenter.getDescription(); var commentdate = eventitem.source.getLastModifiedDate(); var commentversion = eventitem.source.getVersion(); //Call the service to update PowerTools.Model.Services.AppDataServices.Append("ext:ItemCommenting", commentitemid, "<comment><user>" + commenterid + "</user><message>" + comment + "</message><datetime>" + commentdate + "</datetime><version>" + commentversion + "</version></comment>", null, null, null, false); };
This works fine except that the commentername variable is always undefined. Is there a better approach for getting a username and description?
Also, does anyone know if the value returned by eventitem.source.getCreatorId() is really a Reviser or actually the person who created the element?
Thanks in advance
tridion tridion-2011
Chris summers
source share