Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello,
Is it possible to get an array of string arrays from a workflow expression code to a global variable? If yes, what data types should be used?
I tried defining java.util.ArrayList<String[]> type as a global var, but the workflow properties dialog just doesn't allow that.
Following codes create a local array of arrays.
Code from workflow's expression robot:
System.out.println("Start of Test");
java.util.ArrayList<String[]> wfTestTblArr = ext.test.workflow.TestClass.arrayTestMethod();
System.out.println("Following comes from the workflow itself");
System.out.println("Test array size: " + wfTestTblArr.size());
System.out.println("Test array [3rd row, 2th col]: " + wfTestTblArr.get(2)[1]);System.out.println("End of Test");
Code from custom class:
package ext.test.workflow;
public class TestClass {
/**
*
* @return testTblArr
*/
public static java.util.ArrayList<String[]> arrayTestMethod() {// Initialize an empty array of string arrays
java.util.ArrayList<String[]> testTblArr = new java.util.ArrayList<String[]>();
int row = 1;
while (row <= 10) {
// insert values into the row
java.lang.String[] insertRowArr = {
"val_" + row + "_" + 1
,"val_" + row + "_" + 2
,"val_" + row + "_" + 3
,"val_" + row + "_" + 4
,"val_" + row + "_" + 5
,"val_" + row + "_" + 6
,"val_" + row + "_" + 7
};
// insert row into the table array
testTblArr.add(insertRowArr);row++;
}
System.out.println("------------------------------------------------");
System.out.println("All data from the Test table follows");
System.out.println("------------------------------------------------");
// retrieve all values from the test array
for(int i = 0; i < testTblArr.size(); i++) {
System.out.println("------------------------------------------------");
System.out.println("Row number: " + (i + 1));
System.out.println("------------------------------------------------");
String[] retrievedRowArr = new String[7];
retrievedRowArr = testTblArr.get(i);
for(int j = 0; j < retrievedRowArr.length; j++) {
System.out.print(retrievedRowArr[j]);
System.out.print("\n");
}
}
System.out.println("------------------------------------------------");
System.out.println("Test array [1st row, 6th col]: " + testTblArr.get(0)[5]);
System.out.println("------------------------------------------------");
return testTblArr;
}}
Code's output to log:
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Start of Test
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - All data from the Test table follows
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_1_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_1_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_1_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_1_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_1_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_1_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_1_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_2_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_2_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_2_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_2_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_2_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_2_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_2_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_3_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_3_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_3_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_3_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_3_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_3_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_3_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_4_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_4_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_4_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_4_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_4_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_4_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_4_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_5_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_5_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_5_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_5_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_5_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_5_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_5_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_6_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_6_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_6_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_6_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_6_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_6_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_6_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_7_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_7_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_7_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_7_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_7_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_7_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_7_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 8
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_8_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_8_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_8_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_8_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_8_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_8_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_8_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 9
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_9_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_9_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_9_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_9_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_9_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_9_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_9_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Row number: 10
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_10_1
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_10_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_10_3
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_10_4
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_10_5
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_10_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - val_10_7
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Test array [1st row, 6th col]: val_1_6
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - ------------------------------------------------
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Following comes from the workflow itself
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Test array size: 10
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - Test array [3rd row, 2th col]: val_3_2
2016-09-20 11:47:05,253 INFO [WfUserWorkQueue.PoolQueueThread-2] wt.system.out Administrator - End of Test