my structure in SharePoint 2013 is something like this:
- RootSiteCollection
- RootWebSite
- ListA
- SubSiteCollection
- SubWebSite
- Page
- SubWebSite
- RootWebSite
And now I need to create an item in the 'ListA'
What I tried:
function Report(Data) {
var Context = new SP.ClientContext.get_current();
var Site = Context.get_site();
var Website = Site.get_rootWeb();
var List = Website.get_lists().getByTitle('ListA');
var ItemCreation = new SP.ListItemCreationInformation();
var TimeCode = (new Date).getTime();
var Item = List.addItem(ItemCreation);
Item.set_item('FileLeafRef','Test_'+TimeCode);
Item.set_item('Title','Test_'+TimeCode);
Item.set_item('Data',Data);
Item.update();
Context.load(Item);
Context.executeQueryAsync(onFolderCreationSuccess, onFolderCreationFail);
function onFolderCreationSuccess() {
}
function onFolderCreationFail(sender, args) {
alert('Error:' + args.get_message());
}
}
My Problem: The code tries to find the ListA in the SubSiteCollection. But I thought "get_rootWeb()" sound´s like real root. What is the trick and how can I create an item in the ListA from my Page?