Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to create a Ribbon Custom Action in SharePoint 2013 that will e-mail links of selected documents in a document library. I can get the Item ID's of selected items, but how can I use these to create a URL to insert into the e-mail body?

My javascript so far:

var items = SP.ListOperation.Selection.getSelectedItems();

window.location.href="mailto:user@example.com?subject=Subject&body="+items[0].ID+"message%20goes%20here";

Edit: Found a solution below

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I found a solution to my question. I had to use JavaScript to look in the elements on the page for the href value for each list item.

var items = SP.ListOperation.Selection.getSelectedItems();
var url = "";
var length = items.length;
for (var i=0; i<length; i++)
{
url = url + "%0D%0A" + document.getElementById(items[i].id).getElementsByTagName("a")[0].href;
}
window.location.href="mailto:?subject=Subject&body="+url;

I blogged about it here: http://leochensharepoint.blogspot.com/2013/04/using-javascript-with-custom-actions-in.html

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.