i need create ribbon button for copying selected documents from one library to another library that i choose. i found javascript code that copy selected documents to library 'shared documents'. the code is
<code>
function RibbonButtonHandler() {var context = SP.ClientContext.get_current();
var web = context.get_web();
context.load(web);
var _destinationlib = web.get_lists().getByTitle('Shared Documents');
context.load(_destinationlib);
var notifyId;
var currentlibid = SP.ListOperation.Selection.getSelectedList();
var currentLib = web.get_lists().getById(currentlibid);
var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
var count = CountDictionary(selectedItems);
for (var i in selectedItems) {
alert(' ' + count + ' м/');
var currentItem = currentLib.getItemById(selectedItems[i].id);
context.load(currentItem);
var File = currentItem.get_file();
context.load(File);
//Excecuting executeQueryAsync to get the loaded values
context.executeQueryAsync
(
function (sender, args) {
if (File != null) {
var _destinationlibUrl = web.get_serverRelativeUrl() + _destinationlib.get_title() + '/' + File.get_name();
File.copyTo(_destinationlibUrl, true);
notifyId = SP.UI.Notify.addNotification('' + File.get_serverRelativeUrl() + 'to' + _destinationlibUrl, true);
//Excecuting executeQueryAsync to copy the file
context.executeQueryAsync(
function (sender, args) {
SP.UI.Notify.removeNotification(notifyId);
SP.UI.Notify.addNotification(' ', false);
},
function (sender, args) {
SP.UI.Notify.addNotification(' ', false);
SP.UI.Notify.removeNotification(notifyId);
showError(args.get_message());
});
}
},
function (sender, args) {
alert(' ' + args.get_message());
}
);
}
}
</code>
how solve this problem? problem is line var _destinationlib = web.get_lists().getByTitle('Shared Documents');. Can i make the changes in javascript that instead shared documents i can choose some library between more libraries?