for(var i=1 ; i<= foundset.getSize() ; i++)
{
var record = foundset.getRecord(i)
record.myField = "abc"
}
I wondered whether with that setup the last record in a set would be processed or not. I ran a test with five records.
controller.loadAllRecords();
var size = foundset.getSize();
controller.setSelectedIndex(1);
for ( var i = 1 ; i <= foundset.getSize(); i++ )
{
var record = foundset.getRecord(i);
var id = record.seven_id;
var client = record.comid$sev_to_com.company_name;
}
When it came to the last record it processed the first two lines but failed to process the last line. Therefore I changed the loop instructions to:```
for ( var i = 1 ; i <= foundset.getSize() + 1; i++ )
What's going on here? How can one be sure that all lines are executed for the last record?
Here's yet another loop structure:
controller.loadAllRecords();
controller.setSelectedIndex(1);
var size = foundset.getSize();
for ( var i = 0 ; i <= size ; i++ )
{
controller.setSelectedIndex(i);
var id = seven_id;
var client = comid$sev_to_com.company_name;
}
This one processes all lines of all records and then exits.
controller.loadAllRecords();
var size = foundset.getSize();
controller.setSelectedIndex(1);
for ( var i = 1 ; i <= foundset.getSize(); i++ )
{
var record = foundset.getRecord(i);
var id = record.seven_id;
var client = record.comid$sev_to_com.company_name;
plugins.dialogs.showInfoDialog( 'Info', client + ' Success');
}
By inserting a command of substance, not just setting another variable, as the last instruction, the above loop does indeed cycle right through, including the last record. Good to know.
controller.loadAllRecords();
for ( var i = 1 ; i <= foundset.getSize(); i++ )
{
var record = foundset.getRecord(i);
column1 = record.seven_id;
column2 = record.comid$sev_to_com.company_name;
}
column1 and column2 are REAL columns in the database!
Try it!