I have a problem where I have table A - which has 3 fields making up the primary key (pid, iid, sid)
The user loads a table view form with 10 records.
The user then wishes to omit this record based on the primary keys from the multiple rows selected
eg
ROWNUM pid iid sid
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
6 6 6 6
7 7 7 7
8 8 8 8
9 9 9 9
10 10 10 10
My Code is as follows
var pks = new Array(3);
var keep_ids = new Array();
var remove_ids = new Array();
for ( var i = 1 ; i <= forms.list.foundset.getSize(); i++ )
{
pks [0,0] = forms.list.foundset.getRecord(i).iid ;
pks [0,1] = forms.list.foundset.getRecord(i).pid ;
pks [0,2] = forms.list.foundset.getRecord(i).sid ;
//checks if item has been selected and places it into the correct array
if ( !globals.multi_select_is_record_selected('seis_set_inventory_list1', pks ) )
{
keep_ids.push(pks);
}
else
{
remove_ids.push(pks);
}
}
//load foundset with the arrays the user wishes to keep
forms.seis_set_inventory_list1.foundset.loadRecords(databaseManager.convertToDataSet(keep_ids));
//Update UI
application.updateUI();
I was wondering if anyone could tell me what I am doing wrong and how I could solve this issue.
You are reusing the same array object, the second loop run overwrites the first one.
Try this:
var keep_ids = new Array();
var remove_ids = new Array();
for ( var i = 1 ; i <= forms.list.foundset.getSize(); i++ )
{
var pks = new Array(3);
pks [0] = forms.list.foundset.getRecord(i).iid ;
pks [1] = forms.list.foundset.getRecord(i).pid ;
pks [2] = forms.list.foundset.getRecord(i).sid ;
//checks if item has been selected and places it into the correct array
if ( !globals.multi_select_is_record_selected('seis_set_inventory_list1', pks ) )
{
keep_ids.push(pks);
}
else
{
remove_ids.push(pks);
}
}
//load foundset with the arrays the user wishes to keep
forms.seis_set_inventory_list1.foundset.loadRecords(databaseManager.convertToDataSet(keep_ids));
I tried your suggestion and it is one step closer, however, I am getting an exception of “Arguments {0:java.lang.ArrayIndexOutOfBoundsException: 1,length:1}” when I try to run the
I checked the databaseManager.convertToDataSet(keep_ids) and that seems to be returning fine. Which leads me to believe i am doing something incorrectly with the foundset.loadRecords method or that my set up of the keep_ids array is not in the correct format for the foundset.loadRecords.
Is there a specific way in which an array with the multiple keys needs to be set up?
databaseManager.convertToDataSet() does not support multi-dimensional arrays, you will have to create a dataset and add rows to them.
Rob
var keep_ids = databaseManager.createEmptyDataSet(0, 3)
var remove_ids = databaseManager.createEmptyDataSet(0, 3)
for ( var i = 1 ; i <= forms.list.foundset.getSize(); i++ )
{
var pks = new Array(3);
pks [0] = forms.list.foundset.getRecord(i).iid ;
pks [1] = forms.list.foundset.getRecord(i).pid ;
pks [2] = forms.list.foundset.getRecord(i).sid ;
//checks if item has been selected and places it into the correct array
if ( !globals.multi_select_is_record_selected('seis_set_inventory_list1', pks ) )
{
keep_ids.addRow(pks);
}
else
{
remove_ids.addRow(pks);
}
}
//load foundset with the arrays the user wishes to keep
forms.seis_set_inventory_list1.foundset.loadRecords(keep_ids);
I have been able to get around the issue with your suggestion.
I create a dataset from the foundset, loop through the records, and remove any matching rows from the dataset and reload the records when all selected records have been removed.