Getting values from Object by Object Key
Hello! I'm trying to get an object value by its key. It seems to work fine if i manually get the ID (i.e. $clinics.Map.get("784423").NME) but when I use a variable instead of the manual number (i.e. $clinics.Map.get($string_item).NME) it always prints out the last item in the reminder list object, which in the below code is $lead.reminderNextAppt4ClinicID. Any ideas?
Here is a sample of the Array:
#set($clinics = {})
#set( $clinics.Map = {"1535262":{"CID":10115,"LCID":1535262,"NME":"Lifemark Saint John","ADDR1":"206-555 Somerset St.","ADDR2":"","CTY":"Saint John","PROV":"New Brunswick","PC":"E2K 4X2","TEL":"(506) 642-7872","EM":"saintjohn@lifemark.ca","LAT":45.28752,"LNG":-66.081231,"DIRNME":"Cathy Simon","GDIR":"node/1262/maps/dir","GPSVY":"search.google.com/local/reviews?placeid=ChIJu96SdUWzp0wRTeHgxkeVb50","FBU":"https://www.facebook.com/lifemark.saintjohn","CBR":"Lifemark Physiotherapy"},"184410":{"CID":10131,"LCID":184410,"NME":"Lifemark McKenzie","ADDR1":"1555 McKenzie Avenue","ADDR2":"Suite 275","CTY":"Victoria","PROV":"British Columbia","PC":"V8N 1A4","TEL":"(250) 477-1441","EM":"mckenzie@lifemark.ca","LAT":48.467892,"LNG":-123.332512,"DIRNME":"Chris Josue","GDIR":"node/1263/maps/dir","GPSVY":"search.google.com/local/reviews?placeid=ChIJkVSGseBzj1QRV31xZtPQZ9Q","FBU":"https://www.facebook.com/lifemark.mckenzie","CBR":"Lifemark Physiotherapy"})
This is the code I use to grab the array contents. $lead.reminderNextApptxClinicID refers to the user account settings value, which works fine.
#set($reminderList = {})
$reminderList.put($lead.reminderNextAppt1ClinicID,'')
$reminderList.put($lead.reminderNextAppt2ClinicID,'')
$reminderList.put($lead.reminderNextAppt3ClinicID,'')
$reminderList.put($lead.reminderNextAppt4ClinicID,'')
#foreach( $item in $reminderList.keySet())
#set($string_item = $convert.toString( $item ) )
#set($clinic = $clinics.Map.get( $item ) )
ID from Object: $item ##works correctly
ID from Object converted .toString(): $string_item ##returns the same output as the ID from Object above
ID from Object converted .toString() used in clinics.Map object: $clinics.Map.get($string_item).NME ##this just prints out code
ID set manually with a string from clinics.Map object: $clinics.Map.get("784423").NME ##this gets the correct value
#end