function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael MMichael M 

How to fetch items from Map<Date, SeekExtension.DataWrapper>

Hello, I have a class called SeekExtension, in which there is a datawrapper class like this Public Class DataWrapper{
String toDate;
String NPI;
String locationType;    
}

In that class, I have instantiated some DataWrapper class instances and added to a map like this: Map<Date, DataWrapper>.



Now, I have a second class in which I am calling those maps. My questoin is, how can I fetch the details of the DataWrapper class from those Maps? E.g. I want to see the toDate string and the NPI string. How can I get those when my map is my starting point?
Best Answer chosen by Michael M
Suraj Tripathi 47Suraj Tripathi 47

Hi Michael,

Once your map is filled then after iterating over the map of keyset you can get the values. You can take reference from the below code.

SeekExtension.DataWrapper obj=new SeekExtension.DataWrapper();
        obj.toDate=string.valueOf(System.today());
        obj.NPI='Test';
        obj.locationType='Text';
        Map<Date, SeekExtension.DataWrapper> MapName=new Map<Date, SeekExtension.DataWrapper>();
        MapName.put(Date.today(),obj);
        for(Date d:MapName.keySet()){
            system.debug('toDate::::: '+MapName.get(d).toDate);
            system.debug('NPI::::: '+MapName.get(d).NPI);
        }
     }

Please let me know it is working or not?

If it helps you please mark it as Best Answer so that other people would take reference from it.

Thank You!