How to override context variable?

Six Stars

How to override context variable?

Hi,

 

I want to change the value of a context variable and save it permanently in a context file.

 

Here is what I tried already : 

context1.PNGcontext2.PNG

 

The System.out.println() gives me a "b", but when I go into the file written by the tContextDump component it still prints an "a" :

 

context3.PNG

 

Thanks for the help.


Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: How to override context variable?

Hi,

You need to use tContextLoad to update your context, so you need to follow this design:

Capture.PNG

As you see the context contains 3 variables. tLogRow_45 gives the initial values for them.

In tJavaRow, I set the value of the "sample" variable like this before to use tContextLoad:

output_row.key = input_row.key;
if(input_row.key.equals("sample"))
  output_row.value = "100";
else
  output_row.value = input_row.value;

Then the next tContextDump gives me the expected result as you can see.

That's for the principle, maybe there is other approach to do that.

 


TRF

All Replies
Forteen Stars TRF
Forteen Stars

Re: How to override context variable?

Hi,

You need to use tContextLoad to update your context, so you need to follow this design:

Capture.PNG

As you see the context contains 3 variables. tLogRow_45 gives the initial values for them.

In tJavaRow, I set the value of the "sample" variable like this before to use tContextLoad:

output_row.key = input_row.key;
if(input_row.key.equals("sample"))
  output_row.value = "100";
else
  output_row.value = input_row.value;

Then the next tContextDump gives me the expected result as you can see.

That's for the principle, maybe there is other approach to do that.

 


TRF
Six Stars

Re: How to override context variable?

Thank you
Forteen Stars TRF
Forteen Stars

Re: How to override context variable?

You're welcome

TRF