Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Get global var value in THMAP

Hi guys,
sorry if my question was already answered, but i found nothing talking about the way to get tSetGlobalVar value into THMAP.
I tried functions : special->GetVariable, and general->Constant by 2 ways : just writing var name, and calling globalMap getter :

(String)globalMap.get("my var")



Thanks a lot,
Have a good day
ps: sorry for my poor english

Labels (2)
2 Replies
Anonymous
Not applicable
Author

What you have here, is the correct way to get something off the globalMap, if the key value is "my var".
You should null test and type check as well.
If it is not working for you, then the following method is a quick and dirty way of seeing what is on the globalMap and this may help you to track down a missing global.
You can either create a routine or put the relevant code in a tJava.

/**
* Shows they keys of a Map instance. 
* @param mapName
* @param map
* usage showMapKeys("globalMap" globalMap);
*/
public static void showMapKeys(String mapName, java.util.Map map) {
java.util.Iterator iterator = map.keySet().iterator();
java.util.List<String> keys = new java.util.ArrayList<String>();

while(iterator.hasNext()) keys.add(iterator.next().toString());
java.util.Collections.sort(keys);

for(int i = 0; i < keys.size(); i++)
System.out.println(mapName + ": " + i + ": " + keys.get(i));
 //Object value = globalMap.get(key);
}
Anonymous
Not applicable
Author

Thank you tal00000, 
I have already checked my map content before. My question was : How get globalMap value when using thmap componant.
Have a nice day