Hi,
I try to creating a SharePoint 2013 Hosted app that get a selected listitem and move it to another folder of library in the same web.
When I debug my code everything runs without any error. The only problem that I have is that the ‘File.moveTo(destinationUrl,true);’ command not works in the ‘context.executeQueryAsync’ function.
I hope that someone can help me further with this.
This is my move function:
function moveListItem() {
SP.SOD.executeFunc('sp.js','SP.ClientContext', getUrl);
function getUrl() {
var scriptbase = hostweburl +"/_layouts/15/";
$.getScript(scriptbase + "SP.Runtime.js",
function () {
$.getScript(scriptbase + "SP.js",
function () { $.getScript(scriptbase +"SP.RequestExecutor.js", execOperation); }
);
}
);
}
}
function execOperation() {
// Load current Web
context = new SP.ClientContext(appweburl);
var factory =new SP.ProxyWebRequestExecutorFactory(appweburl);
context.set_webRequestExecutorFactory(factory);
appContextSite = new SP.AppContextSite(context, hostweburl);
web = appContextSite.get_web();
context.load(web);
// Load source list
list = web.get_lists().getById(selectedListID);
context.load(list);
//load source listitem
sourceItem = list.getItemById(selectedItemID);
context.load(sourceItem);
var File = sourceItem.get_file();
context.load(File);
context.executeQueryAsync(function (sender, args) {
if (File !=null) {
var bibName = document.getElementById('biburl').value;
var fileName = File.get_name();
var destinationUrl = hostweburl + bibName + fileName;
File.moveTo(destinationUrl, true);
}
});
}
Thanks in advance,
Johan