I have requirement in my SP 2010 Site's SPlist and get all the items including attachments(docx files are attached with all these list ite,s - listitem count is 5500 ) using javascript and client object model and i need to insert these list items into the O 365 -SPO - team site's splist.
Steps I have done: Created a content editor web part in SP 2010 site page Wrote the code for getting all items from splist am stuck with how to insert these list items , along with attachments int SPO site's list?
// load all necessary sharepoint javascript libaries
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
// load the sharepoint list.
loadSharepointList();
});
// loads the sharepoint list
function loadSharepointList() {
// create the sharepoint content.
var context = SP.ClientContext.get_current();
// get the list by the title.
var list = context.get_web().get_lists().getByTitle('Sample List');
// create the query.
var caml = new SP.CamlQuery();
caml.set_viewXml('');
// get the list items asynchronously
var listItems = list.getItems(caml);
context.load(listItems , 'Include(Title)');
context.executeQueryAsync(
// success delegate
Function.createDelegate(this, function() {
// loop through the items.
var listEnumerator = listItems.getEnumerator();
while (listEnumerator.moveNext()) {
// get the current list item.
var listItem = listEnumerator.get_current();
// get the field value.
var fieldValue = listItem.get_item('Title');
}
}),
// error delegate
Function.createDelegate(this, function() {
alert('Error fetching data from Sharepoint!');
}));
}