0

I have a Map<string, Map<String, String>> map1 containing the object as the outer key and the value contains field api name and the label (the label is something which i want to use and not the actual field label) for example:

{
  opportunity={Name=Name information,
   StageName=Stage Name Details,
   Channel__c=channel}
}. 

I have another Map<string, Map<String, Object>> map2 containing the object as the outer key and the value contains field api name and its value. for example:

{opportunity={Name= new opportunity, stageName= understand customer}.

Now i want to merge the two maps so that map2's value contains field label instead of field api name by fetching the field label from map1 and the map should look like the following:

Map<string , Map<String, String>> map3--> 
{
  opportunity={
    Name information= new opportunity, 
    stage Name Details= understand customer
}

Also, map1 has the label Channel__c=channel but this channel__c field is not present in map2. Hence map3 should contain channel=''. i need to display map3 in a table format with the field label as the column name and since channel__c is not present in map2, channel column should contain its value as blank in the table. Is this possible?

2
  • 3
    Field labels are not unique. It is unwise to use them as map keys. Stepping back and providing more detail on what end goal you are trying to achieve may reveal a simpler, more reliable solution.
    – David Reed
    Commented Apr 19, 2020 at 14:43
  • The labels will be set as unique. So in this case using map1 and map2, can map3 be constructed?
    – Raksha
    Commented Apr 19, 2020 at 16:24

0

You must log in to answer this question.

Browse other questions tagged .