How to check a value in a context List Of Value LOV

Six Stars

How to check a value in a context List Of Value LOV

Hello,

 

I try to test if my current value is in my context List of value but it's not ok.

 

My context 'ids' (list of value) = <45,57>

 

if ((context.ids).contains(current_id))

{
   System.out.println("OK");
}
else
{
   System.out.println("KO");
}

 

Result :

 

OK : 45
KO : 49
KO : 50
KO : 51
KO : 53
KO : 57
KO : 62

 

Do you have an explication ?

 

Thanks !!

Tags (1)
Eleven Stars

Re: How to check a value in a context List Of Value LOV

List of values in context is used only to select context value before running jod  (when checking context checkbox).

you cannot access list Durring job running. only the selected one.

if you dont check checkbox you are using the fist data of the list.

 

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Twelve Stars

Re: How to check a value in a context List Of Value LOV

in 7 - it not work at all (Talend error), but if in 6.4 add 

System.out.println(context.ids);

 

it will always print only first element

context.ids - in Talend still String (not array list), You can test it by try use .add method

 

at the same time, if You test
in StartCode section of tJavaFlex:

ArrayList<String> ids = new ArrayList<String>(4);
ids.add("45");
ids.add("24");
ids.add("57");
ids.add("89");

and then in main:

if (ids.contains(row1.current_id))
{
   System.out.println("OK");
}
else
{
   System.out.println("KO");
}

it would print all as expected:

OK

KO

OK

KO

current_id in test - 45,23,57,88

-----------
Eleven Stars

Re: How to check a value in a context List Of Value LOV

it's not an error. it's a feature.

it's list of possible context. but jib run with only one context.

you have to use the checkbox in context tab to have access to the dropdown list before running job.

 

when run:

-Compile

-Select Context

-Run job using selected context

 

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Twelve Stars

Re: How to check a value in a context List Of Value LOV

error - not related to question, TOS 7.01 -0 just not work with List OF Valuers ... completely Smiley Happy

Screen Shot 2018-06-13 at 10.18.25 PM.pngScreen Shot 2018-06-13 at 10.19.33 PM.png

-----------