That returns foundset-dot-table_object. Just need the table object. Several ways to do it:
//whats the name of the pk
var jsTable = databaseManager.getTable(foundset.getDataSource()) // or databaseManager.getTable('db:/dbName/tableName')
if (jsTable) {
//assumes only 1 pk
var pkName = jsTable.getRowIdentifierColumnNames()[0]
}