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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Edith1
Creator
Creator

How to set context boolean variable in tJavaRow output

I want to change the Boolean context variable based if the data field is null. I have tMap connected to outputs tJavaRow & tLogRow_3.

 

Here's what

I have in the tJavaRow code:

 

output_row.entity_id

= input_row.entity_id;

if

(input_row.entity_id != "")

{

 context.Has_Objects

= true; 

}else

context.Has_Objects

= false;  

System.out.println(context.Has_Objects);

 

Here's what

happens when I run the job - it sets the context to true when there's an id,

but nothing is written when there's no id. 

The tLogRow_3

shows the 1st record has ids and variable was set to true, however the 2nd

record there was no id and I don't see the variable set to false. 

0693p000008veplAAA.png

Labels (2)
3 Replies
Anonymous
Not applicable

Hi

Change your code to:

output_row.entity_id

= input_row.entity_id;

if

(!input_row.entity_id.equal(""))

{

 context.Has_Objects

= true; 

}else{

context.Has_Objects

= false;  

}

System.out.println(context.Has_Objects);

 

Please try and let me know if it works.

 

Regards

Shong

 

Edith1
Creator
Creator
Author

Hi @Shicong Hong​, when I changed it to the code you provided, I am getting the following error:

 

"Detail Message: The method equal(String) is undefined for the type String. There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio."

 

I checked my preferences and do have -Xms256M and -Xmx1024M for Job Run VM arguments under the Run/Debug tab and I also have Java Compiler level to 1.8 and use default compliance setting. Anything else that I'm missing for this to work?

 

Anonymous
Not applicable

@Edith Murillo​ , sorry, there is a typo in the code, change it to:

output_row.entity_id

= input_row.entity_id;

if

(!input_row.entity_id.equals(""))

{

 context.Has_Objects

= true; 

}else{

context.Has_Objects

= false;  

}

System.out.println(context.Has_Objects);