Foundset from highlighted in multi-select table view

I know I can do this:

var aToDelete = forms[formName].foundset.getSelectedIndexes();

But how can I get a secondary foundset of these records, without changing the original foundset? I would like to use convertFoundSet to get (and ultimately delete) the relateds as well.

Thank you,
Don

Hi djlapin

You can try something like this

	// Get Selected records ids into an array 'arrayIDs'
	var arrayJsRecords = foundset.getSelectedRecords();
	var arrayIDs = new Array();
	for (var x in arrayJsRecords){
		arrayIDs.push(arrayJsRecords[x].id);
	}
	
	// Format the String value of the array removing '[' and ']'
	// So the query will be like "SELECT ID FROM MY_TABLE WHERE ID IN (1,2,3)"
	var stringArrayIds = arrayIDs.toString();
	stringArrayIds = utils.stringReplace(stringArrayIds,"[","");
	stringArrayIds = utils.stringReplace(stringArrayIds,"]","");
	
	// Get a dataset from the query
	var fs = databaseManager.getFoundSet(controller.getDataSource());
	var table_name = databaseManager.getDataSourceTableName(controller.getDataSource());
	var server_name = databaseManager.getDataSourceServerName(controller.getDataSource());
	var sql_query = "SELECT ID FROM " + table_name + " WHERE ID IN ( " + stringArrayIds + ")";
	var ds = databaseManager.getDataSetByQuery(server_name,sql_query,null,-1);
	
	// Populate the foundset with the dataset
	fs.loadRecords(ds);

Best regards. Roberto Blasco.

Hi Roberto,

I did something similar to what you describe. I had been hoping that convertFoundSet (or something like it) would make all the relations without running the loop and the sql statement…these seem like they might be slow for many records.

Thanks very much for responding,
Don