How to update from updateRecord UIAPI in lWC for List of Arrays
I have a lwc component which returns an Array of idString and i would need to pass it to parameter for listofRecords which would check for all the elements and update the name value to us account and update in bulk
can't use apex because of performance and server calls need to use lwc updaterRecord but it's not updating the record Is there any approach wrong in my code
const COLS = [
{label:'Id', fieldName:'Id'},
{label:'name', fieldName:'name'},
];
idString =["1234","4567","7890","2345"];
updateContactRecordus(listOfrecords) {
let promises = [];
listOfrecords.forEach(idsString => {
let fields = {
Name: 'US Account'
};
console.log('Value of fields is'+ fields);
promises.push(updateRecord({ fields }));
});
Promise.all(promises)
.then(result => {
this.showToast('Success', 'Records updated successfully', 'success');
// Optionally, handle any post-update logic here
})
.catch(error => {
this.showToast('Error updating records', error.body.message, 'error');
});
}
showToast(title, message, variant) {
const evt = new ShowToastEvent({
title: title,
message: message,
variant: variant
});
this.dispatchEvent(evt);
}