Search code examples
tridiontridion-2011

Getting the WebDavURL from Tridion Anguilla in the List View


I would like to get the WebDavURL property of an item int he listview using Anguilla for a GUI Extension.

I have the following code but WebDavURL is not returned:

selectedItem = selection.getItems()[0];
var item = $models.getItem(selectedItem);
var webDavUrl = item.getInfo().webDavUrl();

Solution

  • You'll have to actually load the webDavUrl... item.loadWebDavUrl(). You'll have to set an event handler though to notify once the WebDav URL has been loaded as its an asynchronous method. Here's a sample that includes loading and setting an event handler:

    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();
    }
    

    Hope that helps!