Sidebar

Can I retrieve a table from a system variable and use the data

+1 vote
867 views
asked Dec 12, 2013 by brandon-w-8204 (33,270 points)
I have a table in my System Variables. I want to retrieve the entire table and use the contents outside of the qie.doTableLookup.

2 Answers

0 votes
 
Best answer

Another way would be to parse the System Variable table as a csv message model with a header. If you include the parameter to use the header of the System Variable then you can request data by field name.

var table = qie.getVariable('tableTest');
qie.info('Full Table = ' + table);

var parsedTable = qie.parseCSVString(table, true, '"', ',', true, 'UTF-8');

//Loop through each row and return the values for each field
for (var i=0 ; i < parsedTable.getRowCount() ; i++) {
   var field1Value = parsedTable.getNode('ColHeaderFieldName1', i);
   qie.info('field1Value ' + (i + 1) + ' = ' + field1Value);
   var field2Value  = parsedTable.getNode('ColHeaderFieldName2',  i);
   qie.info('field2Value ' + (i + 1) + ' = ' + field2Value);
}

answered Oct 6, 2017 by michael-h-5027 (14,350 points)
+3 votes
Below is some sample code on how to retrieve the different data elements of a Table stored in the system variables.
 
Sample Code:
 
var table = qie.getVariable('tableTest');
 
qie.info('Full Table = ' + table);
 
var parsedTable = qie.parseCSVString(table);
 
// Retreive Fist row or Header Row
qie.info('Header Row = ' + parsedTable.getNode('*[1]'));
 
//Count rows in table for use in for loop
qie.info('Row Count = ' + parsedTable.getCount('*'));
 
//Loop through each row and return the entire row
for (var i=0 ; i < parsedTable.getCount('*') ; i++) {
   var row = parsedTable.getNode('*[' + (i + 1) + ']');
   qie.info('Row ' + (i + 1) + ' = ' + row);
   
   //Count Columns in the Row
   // Convert Row to string for split
   var row1 = row + '';
   var columnCount = row1.split(',');
   qie.info('Row ' +  (i + 1) + ' Column Count = ' + columnCount.length);
   
   // Retreive the column value from a row to use
   for (var j=0 ; j < columnCount.length ; j++) {
      qie.info('Row ' + (i + 1) + ' - Column '+ (j + 1) + ' = ' + parsedTable.getNode((j + 1) + '[' + (i + 1) + ']'));
   }
 
}
 
answered Dec 12, 2013 by brandon-w-8204 (33,270 points)
...