In this post we will discuss about how to add a list item to a SharePoint Online list using SharePoint Client object model.
Also you can check out:
- How to Get Current Logged in User and Display Name using SharePoint 2013 REST API?
- Prevent new sites to be added to content databases in SharePoint 2013
- SharePoint 2013 Boundaries and Limits
Below is the JavaScript Client Object Model Code. You can put a Content Editor Web Part to add the below code to the SharePoint 2013 online public site.
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var list = web.get_lists().getByTitle('MyTestList');
var name = document.getElementById('firstname').value;
// Create a new list item
var itemCreateInfo = new SP.ListItemCreationInformation();
var listItem = list.addItem(itemCreateInfo);
listItem.set_item('Title',name );
listItem.update();
This code will work for the user who has permission.
Also you can check out:
- How to Get Current Logged in User and Display Name using SharePoint 2013 REST API?
- Prevent new sites to be added to content databases in SharePoint 2013
- SharePoint 2013 Boundaries and Limits
Below is the JavaScript Client Object Model Code. You can put a Content Editor Web Part to add the below code to the SharePoint 2013 online public site.
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var list = web.get_lists().getByTitle('MyTestList');
var name = document.getElementById('firstname').value;
// Create a new list item
var itemCreateInfo = new SP.ListItemCreationInformation();
var listItem = list.addItem(itemCreateInfo);
listItem.set_item('Title',name );
listItem.update();
This code will work for the user who has permission.