<html><script src="/SiteAssets/js/jquery.min.js"></script><script type="text/ecmascript">function Savedata(){var clientContext = new SP.ClientContext.get_current();var oList = clientContext.get_web().get_lists().getByTitle('MyList');var itemCreateInfo = new SP.ListItemCreationInformation();this.oListItem = oList.addItem(itemCreateInfo);oListItem.set_item('Column1', 'Welcome');oListItem.set_item('Column2', 'hi');oListItem.update();clientContext.load(oListItem);//alert('Loaded');clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));}function onQuerySucceeded() {alert('Item created: ' + oListItem.get_id());}function onQueryFailed(sender, args) {alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());}</script><body><input type="button" Value="Save" onClick="Savedata()"/></body></html>
Friday, 13 March 2015
SharePoint Create list item using javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment