2

A client has requested to print every selected list item (and its attachments) with one button click. How can this be achieved? Can I add a custom action in the ribbon that detects every list item selected and then prints it's display form?

  • What do they mean? Print each item's details as separate pages or print a tabular view of the selected items? Are the items generic list items or documents in a library? – Alexey Krasheninnikov Nov 5 '14 at 13:34
  • Sorry for bumping an old thread, but the solution in this thread seems to be exactly what I need. Can someone please explain to me how I run the javascript from a custom action? I'm new to Sharepoint but have been goofing around with web development for a while. – Simon Eriksson Jun 26 '17 at 19:51
4

This can be achieved to a certain extent if you, for example, create a list view with appropriately formatted list items and a SharePoint Designer custom action with a javascript like

javascript:{
(function() {
var myctx = SP.ClientContext.get_current(), 
    selected = SP.ListOperation.Selection.getSelectedItems(myctx), 
    list = []; 

for (var item in selected) {
    list.push(selected[item].id);
}; 

if (list.length > 32) {alert("Please select only as many as 32 items at once.");}
else {
    var url = location.origin + "/YOURSITECOLLECTION/Lists/YOURLIST/YOURPRINTVIEW.aspx"
              + "?FilterName=ID&FilterMultiValue="
              + list.join(';'); 

    location.href = url; 
}

})();

}

The target list view may also reference a trivial masterpage to remove unneeded chrome and contain a javascript to invoke the browser's native print dialog.

  • Can this script be used for SP2010 also? – George Oct 9 '15 at 11:33
  • Yes, it works with sp2010 – Alexey Krasheninnikov Oct 9 '15 at 12:33
  • I added this script in "Navigate to URL" section of "View Ribbon" Custom Actions but it doesn't print the select items,rather it filters the selected items and display them in the view. – George Oct 9 '15 at 12:53
  • Repeat: The target list view may also reference a trivial masterpage to remove unneeded chrome and contain a javascript to invoke the browser's native print dialog. – Alexey Krasheninnikov Oct 15 '15 at 14: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.