Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Can i call contextvariable by it value

Can i read context.Variable by its value, lets say 

 

I have 3 context variables in a job

 

Variable Name-----------------Datatype------------Value

context.Student---------------String----------------Name,Email

context.Name-----------------String----------------Meet

context.Email-------------------String-----------------m@gmail.com

 

There is only one component in my job 'tJava', and in that i have written following code:

----------------------------------CODE--------------------------------------------------------------------

 

String student = context.Student;

String[] students = student.split(",");

for ( int i = 0 ; i<students.length;i++)

{

System.out.println(students[i].trim()); //prints Name and Email

System.out.println(context[students[i]]); //want to print the Value of "context.Name" and "context.Email"

}

 

-----------------------------------tJava throws Error-----------------------------------------

 

Please help and let me know if more information needed on this.

 

Regards 

Meet

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Achieved my requirements

Instead of writing

System.out.println(context[students[i]].trim());

 

Got a solution using this :

 

System.out.println( context.getProperty(students[i]).trims() ); 

 

Regards

Meet

 

 

 

View solution in original post

3 Replies
Jesperrekuh
Specialist
Specialist

What's the background story? Elaborate please? What are you trying to achieve?
Are you looking for a way to read and write global variables? globalMap.put / .get ?

Help us out!?
Anonymous
Not applicable
Author

Reading Global variable using its value 

 

Suppose Student contains 'Name'

in my code i'm getting Name as a output and then i want to get value of  "Name" context in my code

 

Regards 

Meet

Anonymous
Not applicable
Author

Achieved my requirements

Instead of writing

System.out.println(context[students[i]].trim());

 

Got a solution using this :

 

System.out.println( context.getProperty(students[i]).trims() ); 

 

Regards

Meet