'JavaScript Map Update field values
I have a JavaScript Map that is created from an Object. How do I update the Map Field Value?
I created the Map like this:
const MapQuoteLine = new Map();
if (lineModels.length) {
lineModels.forEach(function(line) {
MapQuoteLine.set(line.record['Name'], line.record);
})
};
It looks like this:
{"QL-0502520" => Proxy}
key: "QL-0502520"
Value: Compatibility__c: "N"
Configured_Part_Number__c: "ABCD"
Disc_for_Approval__c: 0
Host_Name__c: null
Later in the code I am looping through the Map and I want to update the Compatibility__c field value only. How can I only update the Compatibility__c value? If I do the below it adds another field of Compatibility__c within the Values.
for (var [key, value] of MapQuoteLine.entries()) {
value.Compatability__c = downgradeCompatability(value, record.Compatability__c)
}
{"QL-0502520" => Proxy}
key: "QL-0502520"
Value: Compatibility__c: "Y"
Compatibility__c: "N"
Configured_Part_Number__c: "ABCD"
Disc_for_Approval__c: 0
Host_Name__c: null
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
