I have two methods 1) getSiteIds and 2) fetchSession.
In the first method getSideIds I want to populate an empty Map<String,String> siteIds = new Map<String,String();
with (name, id):
Map<String,String> siteIds = new Map<String,String();
for (Object dataIte : data) {
Map<String, Object> dataMapIte = (Map<String, Object>) dataIte;
String id = (String) dataMapIte.get('id');
Map<String, Object> attributes = (Map<String, Object>) dataMapIte.get('attributes');
String name = (String) attributes.get('name');
siteMap.put(name, id);
finalList.add(name);
}
NOTE: I declared the siteIds map outside of the method with public accessibility, so it should be available to other methods?
In the second method fetchSession I want to search for id of a site and I provide the name:
Data data = new Data();
data.website_id = siteMap.get(selectedSiteName);
I wrote system.debug(data.website_id);
just so I test this but I get null value: Link.
Any suggestions on how can I set the values of the siteIds with the first method and then use the map in the second method?