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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using Context and globalMap from component in a custom Routine

Hi,

I want to reduce all my code from my tJava so I'm trying to use Routine in a Job ToS for ESB 7.1.1.

 

For example :

I'm doing a request from a table :

"SELECT COLUMN_NAME
FROM TABLE 
WHERE TABLE_NAME = '"+context.Table+"'
AND DATA_TYPE = 'DATE'"

and I save the result in an Arraylist in a tJavaFlex:

0683p000009M6w2.png

But when I have to use it in a different tJava I have to do this :

int NbColumnDate = (Integer)globalMap.get("NbColumnDate");
for (int i = 0; i < NbColumnDate; i++)
{
        ColumnDate.add(((ArrayList)globalMap.get("ColumnNameDate")).get(i).toString());
}

So I want to put this in a Routine and just call it when I need to use this code.

I would like to know if it's possible to use context and globalMap var in custom Routine. If yes, can someone show me the way ?

When I try to use globalMap.get("myVar") or context.myVar an error is raised : context cannot be resolved to a variable and globalMap cannot be resolved to a variable.

Thank you for any help,

 

Regards.

 

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

So after many try here is my answer :

My routine :

public static ArrayList<String> arrayListGlobalMap(ArrayList<String> myArray) { 
		ArrayList<String> MyArray = myArray; 
		return MyArray;
	}

The call in my tJava :

ArrayList<String> MyArray = new ArrayList<>();
MyArray = Java_Insert_Routine.arrayListGlobalMap((ArrayList)globalMap.get("myGlobalArray"));

View solution in original post

1 Reply
Anonymous
Not applicable
Author

So after many try here is my answer :

My routine :

public static ArrayList<String> arrayListGlobalMap(ArrayList<String> myArray) { 
		ArrayList<String> MyArray = myArray; 
		return MyArray;
	}

The call in my tJava :

ArrayList<String> MyArray = new ArrayList<>();
MyArray = Java_Insert_Routine.arrayListGlobalMap((ArrayList)globalMap.get("myGlobalArray"));