4

I'm trying to retrieve the webdav url of a component using Anguilla but i see the value to be retrieved as undefined. As suggested by Nuno i'm using

var x = frames[0].$models.getItem(“tcm:1-123”)
x.loadWebDavUrl()
x.getWebDavUrl()

Not only this function but rest all are also resulting as undefined.enter image description here

I'm using the below code in the js file as suggested in stackoverflow question https://stackoverflow.com/questions/14082844/getting-the-webdavurl-from-tridion-anguilla-in-the-list-view

    Extensions.CopyUri.prototype._execute = function CopyUri$_execute(selection) {
    selectedItem = selection.getItems()[0];
   // prompt("Copy the Item ID using Ctrl/Cmd + C:", selection.getItems()[0]);


var item = $models.getItem(selectedItem),
    webDavUrl = item.getWebDavUrl();

if (!webDavUrl) {
    // WebDavUrl for cached item hasn't been loaded yet, so lets load it.
    $evt.addEventHandler(item, "loadwebdavurl", function (event) {
        webDavUrl = item.getWebDavUrl(); // also could do event.source.getWebDavUrl()
    });
    item.loadWebDavUrl();
}
prompt("Webdav Url is ",webDavUrl);
alert(webDavUrl);
}
5
var item = window.top.frames[0].Tridion.getApplicationWindow().$models.getItem("tcm:1-123");
item.loadWebDavUrl();
item.getWebDavUrl();

upd

1\ you should use application window context to get an access to you repository.

var appWindow = window.top.Tridion && window || (function (i, win) { while (!(win = window.top[i++].Tridion)) { }; return win && win.getApplicationWindow();})(0);

2\ shortcuts should also be used in this context

appWindow.$evt.addEventHandler(item, "loadwebdavurl", function (event) { console.log(item.getWebDavUrl()) });

3\ and then load item

item.loadWebDavUrl();
  • Thanks Beardcore..The above solution worked while debugging on chrome console but still i have issues when i put the code in the js file. I'm getting undefined. – Sam Feb 18 '15 at 11:29
  • I can assume that you execute item.getWebDavUrl(); right after load. But load request is done asynchronously, you should track it with $evt.addEventHandler(item, "loadwebdavurl", onLoadcallback); – UI Beardcore Feb 18 '15 at 11:36
  • I updated with latest source code where i'm loading the events – Sam Feb 18 '15 at 11:58

Your Answer

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

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