This post will be a continue of the above two posts. In this post we will be addressing the basic operations on SharePoint list items.

Permission

In order to do operations on the list on host web we need to give permission to the List. In our case we have to set the permission “Scope” to “List” and “Permission” as “Manage”. Please refer the image below.

Click on AppManifest.xml –> Permission

Set “Scope” to “List” and “Permission” to “Manage”

The addinWeb will be the Add-in web url and the hostWeb will be the Host Web url. You may download the solution from the link given at the bottom and refer for more.

Add new Item to List

$pnp.sp.crossDomainWeb(addinWeb, hostWeb).lists.getByTitle("List1").items.add({
Title: "Title"
}).then(function (result) {
alert("Item Added");
//"result" will return couple of properties of newly created item. We can make use of them here
console.log(result.data);
console.log(result.data.Id);
}).catch(function (err) {
alert(err);
});