<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Talend Studio: Can I use a context variable or a global variable in a routine? in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/Talend-Studio-Can-I-use-a-context-variable-or-a-global-variable/ta-p/2150655</link>
    <description>&lt;P&gt;A &lt;STRONG&gt;globalMap&lt;/STRONG&gt; 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:&lt;/P&gt;
&lt;PRE&gt;package routines;
public class MyRoutineDemo {
  
public static String convertName(String parameter) {
  
String name=parameter.toUpperCase();
  
return name;
  
}
}&lt;/PRE&gt;
&lt;P&gt;The following example code in a &lt;STRONG&gt;tJava&lt;/STRONG&gt; component passes the value of the global variable &lt;STRONG&gt;myName&lt;/STRONG&gt; to the routine:&lt;/P&gt;
&lt;PRE&gt;globalMap.put("myName", "shong");
String name=MyRoutineDemo.convertName((String)globalMap.get("myName"));
System.out.println(name);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2024 02:35:30 GMT</pubDate>
    <dc:creator>TalendSolutionExpert</dc:creator>
    <dc:date>2024-01-23T02:35:30Z</dc:date>
    <item>
      <title>Talend Studio: Can I use a context variable or a global variable in a routine?</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Talend-Studio-Can-I-use-a-context-variable-or-a-global-variable/ta-p/2150655</link>
      <description>&lt;P&gt;A &lt;STRONG&gt;globalMap&lt;/STRONG&gt; 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:&lt;/P&gt;
&lt;PRE&gt;package routines;
public class MyRoutineDemo {
  
public static String convertName(String parameter) {
  
String name=parameter.toUpperCase();
  
return name;
  
}
}&lt;/PRE&gt;
&lt;P&gt;The following example code in a &lt;STRONG&gt;tJava&lt;/STRONG&gt; component passes the value of the global variable &lt;STRONG&gt;myName&lt;/STRONG&gt; to the routine:&lt;/P&gt;
&lt;PRE&gt;globalMap.put("myName", "shong");
String name=MyRoutineDemo.convertName((String)globalMap.get("myName"));
System.out.println(name);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 02:35:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Talend-Studio-Can-I-use-a-context-variable-or-a-global-variable/ta-p/2150655</guid>
      <dc:creator>TalendSolutionExpert</dc:creator>
      <dc:date>2024-01-23T02:35:30Z</dc:date>
    </item>
  </channel>
</rss>

