Skip to main content
2 of 3
Formatted the code for readability.
Peter Kjaer
  • 19.8k
  • 1
  • 23
  • 56

You have to use something like this. And they (getcreatorId etc.,) gives you the referrer, not the person who created that item.

PW.Commands.MyTask.prototype._execute = function (selection, pipeline) {  
    var selectedItem = selection.getItems()[0];
    var item = $models.getItem(selectedItem);

    var itemLoad = function (event) {
        var item = this;
        $evt.removeEventHandler(item, "load", itemLoad);
    
        // variable that you want...
        var commentitemid = item.getId();
        var commenterid = item.getCreatorId();
        var commenter = $tcm.getItem(commenterid);
        var commentername = commenter.getDescription();
        var commentdate = item.getLastModifiedDate();
        var commentversion = item.getVersion();
    };


    if (item.isLoaded()) {
        $evt.addEventHandler(item, "load", itemLoad);
        item.load(true);
    }
    else {
        $evt.addEventHandler(item, "load", itemLoad);
        item.load();
    }
};