HOW TO: Copy field contents for a foundset

Better known as “Copy a foundset column”

If you’re working on a project that needs to take data from the database into another program, such as a spreadsheet, then using the copyAllRecords() method may not do the trick (Unless you know how to use the string.split function and loop through an array or two).

Instead, use the databaseManager. Here is the code you need to get the contents of a single field (column), from a foundset, onto the clipboard.

var x = databaseManager.getFoundSetDataProviderAsArray(foundset, 'field_name_here');
var y = ''; //initialize a string variable
for (i = 0; i < x.length; i++) {
	y = y + '\n' + x[i];
}
application.setClipboardContent(y);