• AndyH

Creating a new list item


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}` ); });
19 views

 

© 2019 AndyH  -  all rights reserved