I have a Map that is returned from apex to my LWC. Below is the apex:
public static Map<string, opportunity> existingOppCheck(id accountId, id brokerId, date effDate, id ownerId, List<string> allRecTypes){
/////Map<String, Id> recordTypeMap = new Map<String, Id>();
Map<String, opportunity> recordTypeMap = new Map<String, opportunity>();
List<opportunity> existingOppList = [select RecordTypeId, RecordType.Name, Name, LOB__c, CloseDate, owner.name
FROM Opportunity WHERE AccountId = : accountId and Broker__c = : BrokerId and ownerId = : ownerId
and CloseDate = : effDate and RecordTypeId in : allRecTypes Order By closedate DESC];
for(opportunity opp: existingOppList){
/////recordTypeMap.put(opp.RecordType.Name, opp.RecordTypeId);
recordTypeMap.put(opp.RecordType.Name, opp);
}
return recordTypeMap;
}
When I get the map back, I use it to check a list to see if opps in the list are already created. That works file. But I also want to display a list of the returned opps from recordTypeMap. I am struggling to figure out how I display that. I was trying to assign just the values of the map to a list which I would then display but that is not working. From what I have found, I can't display a map in my lwc so how do I get the values of my map and place them in a list to display? Here is my method where I am calling the apex. In my console.log I see an a label and value but can't figure out how to get just the value. this is what the console.log returns:
zz here is the alreadyCreatedRecTypes [{"label":"New Business Health","value":{"RecordTypeId":"012700000001e8YAAQ","Name":"2024 02 / Health / Test Account 33z / cabde / Broker 1","LOB__c":"Health","CloseDate":"2024-02-01","OwnerId":"00570000001kT0AAAU","Id":"0068A00000ERAS5QAP","RecordType":{"Name":"New Business Health","Id":"012700000001e8YAAQ"},"Owner":{"Name":"Chaunte Abdellah","Id":"00570000001kT0AAAU"}}}]
Here is the javascript method:
Step 2 - get the list of opportunities that are already created (based on account, owner, market and eff date selected)
existingOppCheck({accountId: this.accountId, brokerId: this.selectedBrokerId, effDate: this.selectedEffDate, ownerId: this.selectedOwnerId,
allRecTypes: this.clonedFromOppRecTypes})
.then(data => {
//1. get existing opp record types
this.alreadyCreatedRecTypes = Object.keys(data).map(key => ({
label: key,
value:data[key]
}));
console.log('zz here is the alreadyCreatedRecTypes ' + JSON.stringify(this.alreadyCreatedRecTypes));
Here is the datatable not displaying
<lightning-card title="The following Opps have previously been created with the new criteria you selected" icon-name="action:close">
<lightning-datatable
id="nonCloneableList"
data={alreadyCreatedRecTypes}
columns={noCloneColumns}
column-widths-mode=auto
min-column-width=115
key-field="Id"
class="inActiveRecords"
hide-checkbox-column="true"
>
</lightning-datatable>
</lightning-card>
Thank you!!!