CODE
I'm getting odd behavior from the multi-select.
- Code: Select all
foundset.getSelectedRecords()
I'm doing a process where I'm grabbing the array of records, and doing a forEach of each record and applying a function to each one.
- Code: Select all
// For Every Selected Account
ArrayRecords.forEach(
/**
* @param {JSRecord<db:/example_db/table_test>} record
* @param {Number} index
* @param {JSFoundset} fs
*/
function( record, index, fs )
{
// validate
archive_Records( record.col_id)
}
)
- Code: Select all
/**
*
* @private
* @properties={typeid:24,uuid:"AFAB7AFA-5659-4154-A735-88972A17BADC"}
*/
function archive_Records( ID ) {
/** @type {JSFoundset<db:/example_db/table_test>} */
var fs = databaseManager.getFoundSet( 'example_db', 'table_test' )
/** @type QBSelect<db:/example_db/table_test> */
var query = datasources.db.example_db.table_test.createSelect()
query.where.add(
query.columns.col_id.eq( ID )
)
fs.loadRecords( query )
var fs_updater = databaseManager.getFoundSetUpdater( fs )
fs_updater.setColumn( 'col_flag_archive', 1 )
fs_updater.performUpdate()
databaseManager.saveData( fs )
application.output( "Archived: " + ID )
}
ISSUE
My algorithm seems to run fine and applies correctly. However I'm having an issue with the Multi-Select behavior.
When first open a grid, I can for example select 4 records and then 'archive' them with my algorithm.
I have an 'unarchive' algorithm that is the exact same but changes 1 to 0. I try and apply the Unarchive algorithm, however it only gets apply to 1 record instead of 4... This is when I realized that for some reason, after running my first algorithm that the multi-select de-selects everything automatically and leaves only 1 selected. Even when trying to re-select stuff, only one record is passed by the foundset.getSelectedRecords().
However, when I swap to another form with a grid, then swap back, I'm able to run my Archive algorithm again. I have no idea why or what is going on with this behavior!
GUESS
My guess is that updating the table related to the foundset of the grid freaks out the multi-select.
Any help is appreciated!