I have recently implemented a rename favorites feature for Tridion and in the process I am intercepting the AddUri command and posing a prompt for the user to provide a new name for the favorite.

While testing the feature we have found the AddUri command is sometimes not called for the "Send to My Favorites" click, at least our prompt wasn't showing up in some cases.

For example: I added a page to favorites, my prompt showed up and I gave it a new name. Then I deleted it from the favorites. Then I added the page again to the favorites. This time my prompt for a new name did not show up.

Is there a different command or cache that I need to look at? For now I am refreshing the whole page after every delete of a favorite....

Here is command extension code for AddURI interception:

    <cfg:group name="NewNameFavorites.CommandSet" merge="always"        merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor">
      <cfg:file type="script">/NewNameFavorites/NewNameFavorites.js</cfg:file>
      <cfg:file type="reference">NewNameFavorites.Interface</cfg:file>

        <ext:command name="AddUri" extendingcommand="NewNameFavorites"/>

 <cfg:commandset id="NewNameFavorites.Interface">
     <cfg:command name="NewNameFavorites" implementation="Commands.NewNameFavorites"      />

Here is the JS code:


Commands.NewNameFavorites= function NewNameFavorites() {
    Type.enableInterface(this, "Commands.NewNameFavorites");
    this.addInterface("Tridion.Cme.Command", ["NewNameFavorites"]);

Commands.NewNameFavorites.prototype._isAvailable = function NewNameFavorites$_isAvailable(selection, pipeline) {
    console.debug("Favorites Is Available called");
    if (pipeline)
        pipeline.stop = false;
    return $cme.getCommand("AddUri")._isAvailable(selection, pipeline);

FavoritesReload = function (event) {

Commands.NewNameFavorites.prototype._isEnabled = function NewNameFavorites$_isEnabled(selection, pipeline) {
    console.debug("Favorites Is Enabled called");
    if (pipeline)
        pipeline.stop = false;
    try {
        var view = $display.getView();
        var list = view.getListObject("cme:shortcuts");
        list.removeEventListener("itemadd", FavoritesReload);
        list.removeEventListener("itemupdate", FavoritesReload);

        list.addEventListener("itemadd", FavoritesReload);
        list.addEventListener("itemupdate", FavoritesReload);

    catch (err) {
        console.debug("Favorites Reload Error occured: " + err);
    return $cme.getCommand("AddUri")._isEnabled(selection, pipeline);

Commands.NewNameFavorites.prototype._execute = function NewNameFavorites$_execute(selection, pipeline) {
    console.debug("Favorites Execute called");
    if (pipeline)
        pipeline.stop = false;

    $cme.getCommand("AddUri")._execute(selection, pipeline);

    var arrItems = [];
    //selectedItem = selection.getItems()[0];
    var itemsProcessed = 0;
    var items = Array.clone(selection.getItems());
    var itemsLen = items.length;

    var addFavoritesCustomTitle = function (event) {
        var username = Tridion.ContentManager.UserSettings.getInstance().getUserName();//Tridion.UI.UserSettings.getJsonUserSettings(true).User["@ID"];
        username = username.replace('\\', '\\\\');
        var customTitles = JSON.stringify(arrItems);
        var serviceURL = "/ManageAppData.svc/AddFavoritesCustomTitles";
        var favoriteData = '{"username" : "' + username + '","customTitles" : ' + customTitles + '}'; //
            type: "POST",
            data: favoriteData,
            dataType: "json",
            contentType: 'application/json; charset=utf-8',
            url: serviceURL,
        cache: false,
        success: function () {
        error: function () {
            alert('Error Renaming Favoties!');

var itemLoad = function (event) {
    var item = this;
    var itemId, itemTitle;
    $evt.removeEventHandler(item, "load", itemLoad);
    itemId = item.getId();
    itemTitle = item.getTitle();
    var newTitle = prompt("Enter Title for the Favorite", itemTitle);
    newTitle = newTitle.replace(/[^A-Za-z0-9-_\s]/g, '');
    newTitle = newTitle.trim();
    if (!newTitle) newTitle = itemTitle;

    if (newTitle != itemTitle) {
        if (item && Type.isFunction(item.getTCMItemId)) {
            if (refId = item.getTCMItemId()) {
                itemId = refId;
        newTitle = newTitle.replace(/[^A-Za-z0-9-_\s]/g, '');
        arrItems.push({ "itemId": itemId, "newTitle": newTitle });
    if (itemsLen == itemsProcessed) addFavoritesCustomTitle();

for (var i = 0; i < itemsLen; i++) {
    var item = $models.getItem(items[i]);
    $evt.addEventHandler(item, "load", itemLoad);

  • Can you update your question with a code of interception? Are you doing interception throught command extension? Mar 1, 2013 at 10:27
  • yes UI Beardcore, I am using command extension.... Mar 1, 2013 at 11:10
  • Hi Ram, Might be worth adding your js code to your question and let us know if you see any errors in the browser console?
    – johnwinter
    Mar 1, 2013 at 11:18
  • 1
    Will get back to you later today with a working demo. :)
    – lnaie
    Mar 1, 2013 at 12:31
  • Yes, basically the interesting part is the JS implementation. As it seems like pipeline processing is not going into your command. Mar 1, 2013 at 14:46

2 Answers 2


I assume the problem is in

$evt.addEventHandler(item, "load", itemLoad);

As if Item is loaded, then it wont fire load event onitem.load()`.

you can either do reload: item.load(true) or check if item is loaded

if (item.isLoaded())
    $evt.addEventHandler(item, "load", itemLoad);
  • UI Beardcore, that was it... It fixed the issue perfectly Mar 6, 2013 at 10:26
  • any chance you'll share the full solution?
    – Daryl H
    Jun 16, 2014 at 13:41

As I've promised, I'm back with a skeleton Visual Studio 2010 project that demonstrates a few concepts:

  • a possible structure of a CME Extension Editor within a Visual Studio project
  • editor's configuration to be able to extend the functionality provided by CME Dashboard, as of now (pre 2013 release)
  • and so far, two ways to extend an existing CME command -- e.g. Tridion.Cme.Commands.AddUri, by sub-classing it or by using the command extensions.

Source code is publicly available on github: https://github.com/lnaie/CmeExtEditor

I hope this helps, Lucian

  • Hey Inaie, thanks for the code. But it didnt fix the problem... I have addded my JS code to my question. Mar 5, 2013 at 11:57
  • POC should fix the issue with your command not being called every time user uses "Send to My Favorites". The actual implementation of the command it's also important... but have fun! :)
    – lnaie
    Mar 5, 2013 at 15:12

Your Answer

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

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