1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
602 views
by jon-t-6024 (560 points)
For example, if I have a table full of providers and their associated PAs, and each provider has multiple PAs, can we return all the PAs associated with the provider?

1 Answer

0 votes
 
Best answer

No, doTableLookup cannot return multiple rows.  Fear not, though, as there is a solution.


The solution is to get all the data from the table variable, parse it as a CSV, then cycle through with a for loop to find all the values you want. 

For example:

var tableName = qie.getVariable('Table');
var tableCSV = qie.parseCSVString(tableName, true, '"', ',', true);
 
for (var x=0; x < tableCSV.getRowCount(); x++) {
   if (tableCSV.getNode('Column', x+1) == 'Value') {
    qie.info(tableCSV.getNode('ADifferentColumn', x+1));
   }
}
This code will get the contents of the "Table" table variable, parse it as a CSV (using the first row as a header), then cycle through each row of the CSV to determine if the value in column "Column" matches "Value".
 
You could use this to look for the provider IDs of in the table, and return the items in another column ("ADifferentHeader" in this example), storing or acting on them as needed.
by jon-t-6024 (560 points)
...