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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.

Talend Studio: Can I use a context variable or a global variable in a routine?

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
TalendSolutionExpert
Contributor II
Contributor II

Talend Studio: Can I use a context variable or a global variable in a routine?

Last Update:

Jan 22, 2024 9:35:30 PM

Updated By:

Jamie_Gregory

Created date:

Apr 1, 2021 6:08:17 AM

A globalMap variable or a context variable is not accessible from a routine, because the job class and the routine are two independent units. As a workaround, you can pass the value of a global variable or a context variable as a parameter to your routine. The following example code converts a string to all upper case:

package routines;
public class MyRoutineDemo {
  
public static String convertName(String parameter) {
  
String name=parameter.toUpperCase();
  
return name;
  
}
}

The following example code in a tJava component passes the value of the global variable myName to the routine:

globalMap.put("myName", "shong");
String name=MyRoutineDemo.convertName((String)globalMap.get("myName"));
System.out.println(name);

 

Labels (2)
Version history
Last update:
‎2024-01-22 09:35 PM
Updated by: