Created
July 15, 2013 17:53
-
-
Save vman/6001959 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createListItems() { | |
var itemArray = []; | |
var clientContext = SP.ClientContext.get_current(); | |
var oList = clientContext.get_web().get_lists().getByTitle('TestList'); | |
for(var i = 0; i< 5; i++){ | |
var itemCreateInfo = new SP.ListItemCreationInformation(); | |
var oListItem = oList.addItem(itemCreateInfo); | |
oListItem.set_item('Title', 'My New Item!' + i); | |
oListItem.update(); | |
itemArray[i] = oListItem; | |
clientContext.load(itemArray[i]); | |
} | |
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed); | |
} | |
function onQuerySucceeded() { | |
alert('Items created'); | |
} | |
function onQueryFailed(sender, args) { | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
} | |
createListItems(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment