Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can I retrieve the URL of an item/document in a (generic) document library when the only thing I have is the ID, obtained through:

SP.ListOperation.Selection.getSelectedItems();

My intention is to use the obtained URL to open the document through a link, redirect or in a dialog and execute window.print(); onload(Page_Load).

My code for the dialog window is:

function resultCallback(result, value) {
SP.UI.Notify.addNotification('Success!');
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}

var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var myItems = '';

myItems = items[0].id;


if (myItems != '') {
    var options = {
        url: '{SiteUrl}/_layouts/Benetton_FRA/download.aspx?Items=' + myItems + '&ListId={SelectedListId}&Source={Source}',
        tite: 'My Page',
        allowMaximize: false,
        showClose: true,
        width: 500,
        height: 160,
        dialogReturnValueCallback: resultCallback
    };

    SP.UI.ModalDialog.showModalDialog(options);
}

And the Page_Load part:

protected void Page_Load(object sender, EventArgs e)
    {

        Response.Write("<script language='javascript'>");
        Response.Write("window.print()");
        Response.Write("</script>");
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.