top of page
  • Writer's pictureAndyH

Creating a new list item


Adding an item to a SharePoint list or library title

Using PnPJS to create a new list item is really easy to do with items.add.


In this example a new list item is created, populating the Title. A result is returned and where the Id of the newly created list item can be obtained from.

sp.web.lists.getByTitle( "MyList" ).items.add( { Title: "My new list item" }).then( ( result: ItemAddResult ) => { // result.data.Id contains the Id of the new list item }); }).catch( ( e: Error ) => { alert( `Error creating the item ${e.message}` ); });
27 views0 comments

Recent Posts

See All
bottom of page