Quantcast
Viewing all articles
Browse latest Browse all 6517

New Post: Get Library Item URL

Hi,

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.id + "</Value></Eq></Where></Query>";

    $().SPServices({
        operation: "GetListItems",
        listName: $().SPServices.SPListNameFromUrl(),
        async: false,
        CAMLQuery: query,
        completefunc: function (xData, status) {
            $(xData.responseXML).find("z\\:row").each(function () {
                items.itemData.push({
                    //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.

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>