I have created SPFx web part using React JS framework. I am reading the data from the CSV file and adding item to SharePoint list using inBatch in PnP JS.
I was able to add the item to SharePoint list by passing the parameter name with static value. But I have a requirement of adding the column with it's value dynamically.
Below is the sample to add item with column value like below.
var ItemArray = [];
ItemArray.push(pnp.sp.web.lists.getByTitle('listdisplayname').items.inBatch(batch).add({
Title : "Title"
}));
Promise.all(ItemArray).then(function() {
console.log("Item Added successfully!!");
});
batch.execute();
Please let me know, if there is any way to pass parameter dynamically.
Example:
var ItemArray = [];
var body = "Title : dynamic value"
ItemArray.push(pnp.sp.web.lists.getByTitle('listdisplayname').items.inBatch(batch).add({
body
}));
Promise.all(ItemArray).then(function() {
console.log("Item Added successfully!!");
});
batch.execute();