I'm developing an extension to the Content Manager and I need to capture the TCM when an element is saved to send some data throught a web service. The problem comes when I extend command "SaveNew" and that it's the reason: to get the TCM I have to add a listener to control when the url changes with this code:

$evt.addEventHandler($display.getItem(), "idchange", function(event) {
        //var oldId = event.data.oldId;
        var newId = event.data.newId;

The problem is the Content Manager changes many times the url until you could open a page (when my extension must be executed) and generates an exception with the following error:

Uncaught Error: Value should be an object. at Object.Tridion$Assert$raiseError [as raiseError] (coreresource_v7. at Object.Tridion$Assert$isObject [as isObject] (coreresource_v7. at Tridion$EventRegisterClass.EventRegister$addEventHandler [as addEventHandler] (coreresource_v7. at window.onload (ProxyView_v7.

Is anyone aware this issue? Is it possible to do this in a different approach?

  • Wait, are you adding the event handler every time the URL changes? You don't want to do that -- just do it once. Jun 21 '17 at 9:26
  • Could you control that? I mean, is there any way to control when a url changes only when a new page is created? Jun 21 '17 at 9:40
  • Unless I'm missing something, you really don't care when the URL changes. You only care when the new item gets assigned an ID. That's what the event handler is for. You only need to hook into that once, for instance when your object is initialized. Jun 21 '17 at 11:50
  • Is there an event (like "idchange") to detect when a new element gets assigned an ID? Jun 21 '17 at 12:13
  • If you mean the DOM elements, then no -- there's no event when the uniqueID property is changed. Jun 22 '17 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.