
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to use context variable in a tMap output filter section
Hi All, I am Currently reading data from a source file and I want to filter specific records from a column row1.abc and I am using the below condition
" row1.abc == 1 || row1.abc ==2|| row1.abc ==3 " in tMap output side filter section.
Requirement- I want to pass the values 1,2,3 to the above expression using a context variable in tMap output filter. Please help me how to achieve this. Thanks in advance..!😊
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, so you want all the values in one variable or one variable for each value ?
Send me love and kudos

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Thanks for responding. I want all values in one context variable if possible.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use a context variable
here the name i use is list1 and value is "1,2,3" as String
then in a tJava a the begining of the job
in advanced settings of the tJava:
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
in the basic settings of the tJava :
List<String> str = (Arrays.asList(context.list1.split(",")));
List<Integer> intList = new ArrayList<>();
str.forEach(a-> intList.add(Integer.parseInt(a)));
globalMap.put("intList", intList);
and in the tmap filter output expression :
((List<Integer>)globalMap.get("intList")).contains(row1.abc)
send me love and kudos

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have defined the code in tJava component as you mentioned and created a context variable with string data type and inserted value 22,38,39 in contexts section. But I am getting below error-please advise.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
could you go to the code view and share screen where the error is. you can find it where there is red square. cause i test this particular piece of code and it's working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for sharing your screenshots, I am not able to see any errors in code view. But after I changed my string data type context variable value with enclosed double quotes "22,38,39" I am getting below error upon job run - {"logTimestamp":1644835697403,"severity":"FATAL","logType":null,"logMessage":"tJava_3 For input string: \"\"\njava.lang.NumberFormatException: For input string: \"\"\n\tat java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)\n\tat java.lang.Integer.parseInt(Integer.java:592)\n\tat

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, @guenneguez jeremy !! The solution you provided did work. Appreciate your detailed solution with screenshots. Love and Kudos!
