Get Library Item URL

Aug 2, 2013 at 12:26 AM

I need to get the selected item URL of a document library using jQuery. So I use SPServices library and tried several options. Unfortunately still I'm not getting into the correct track.

This is my code:

function PublishActionRibbon() {
var items = { itemData: [] };
var selectedList = SP.ListOperation.Selection.getSelectedList();
var selectedItems = SP.ListOperation.Selection.getSelectedItems();
var cxt = new SP.ClientContext.get_current();
var web = cxt.get_web();
var list = web.get_lists().getById(selectedList);
var query = '';

$.each(selectedItems, function (i, value) {
    query = "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Number'>" + + "</Value></Eq></Where></Query>";

        operation: "GetListItems",
        listName: $().SPServices.SPListNameFromUrl(),
        async: false,
        CAMLQuery: query,
        completefunc: function (xData, status) {
            $(xData.responseXML).find("z\\:row").each(function () {
                    //here I need to add the item url to the JSON array
                    //"itemUrl": $(this).attr('EncodedAbsUrl'), but the result is undefined
                    "fileName": $(this).attr('ows_LinkFilename'),
                    "owner": $(this).attr('ows_Editor')

Any idea or suggestion is highly appreciated. Thanks.
Aug 5, 2013 at 11:38 AM
Depending on your version of jQuery, this is probably the problem: .find("z\:row"). Switch to SPFilterNode.

If this turns out to be the problem, a little stepping through would probably have caught it, as the .each wouldn't iterate.