My apologies if my question doesn't make sense, and I will try to explain it better...I have an on object and in this object I have an array of objects. I am trying to update one of the found objects in the array of objects, I update the found object but it doesn't update the original object in the array, right now I have this
let vendeeCatalogs = workingVendorImplementorInfo.SVendorCatalogImplementorInfo; // This the array of objects
if (vendeeCatalogs.length > 0) {
for (let i = 0; i < vendeeCatalogs.length; i++) {
foundCatalog = workingVendorImplementorInfo.SVendorCatalogImplementorInfo.find(function (x) { return x.CatalogID == vendeeCatalogs[i].CatalogID });
if (foundCatalog) {
foundCatalog.CatalogGenerationGUID = vendeeCatalogs[i].CatalogGenerationGUID;
foundCatalog.BeginEffectiveDate = vendeeCatalogs[i].BeginEffectiveDate;
foundCatalog.EndEffectiveDate = vendeeCatalogs[i].EndEffectiveDate;
foundCatalog.Multiplier = vendeeCatalogs[i].Multiplier;
foundCatalog.Discount = vendeeCatalogs[i].Discount;
foundCatalog.UOMPrecisionTypeID = vendeeCatalogs[i].UOMPrecisionTypeID;
foundCatalog.IsSelected = vendeeCatalogs[i].IsSelected;
}
}
}
I can see that this is wrong because all it does is updates the foundCatalog, and not the original object that was found. So how do I find the object and update that object so that the changes are saved in the workingVendorImplementorInfo.SVendorCatalogImplementorInfo?
iis used in a callback, it will always bevendeeCatalogs.lengthlet ias the declaration.letuses block scope, so the value ofiwill be correct on each iteration. (Not to mention, the callback here is synchronous, so it wouldn't matter either way, it'll still work.)(x) => x.CatalogID == vendeeCatalogs[i].CatalogID