Looping more than 400

I have a loop which needs to process ALL records which satisfy a particular relationship – controller.loadRecords(relationship). However only the first 400 records are processed.

How can I ensure that ALL records which satisfy the relationship get processed within the loop?

Appreciated.

Morley, what does your loop look like. Without that info we can’t help you…

IT2BE:
Morley, what does your loop look like. Without that info we can’t help you…

I’m looping through all the Company records, testing whether they have permission to update categories. If the current record does then jump to the Categories table. Here each of the defined categories is looped through testing whether there are records for the current company for that category in the CatItems table. If not, create them. A loop within a loop. Here’s the Company loop:

controller.loadRecords(gsevid$to_com);
forms.catUtility.controller.loadRecords(catkind$com_to_cat);
var max = controller.getMaxRecordIndex() + 1;
// var max = 3; // for test purposes

for ( var i = 1 ; i < max ; i++ )
{
	var record = foundset.getRecord(i);
	
	var comid = record.company_id;
	var name = record.company_name;

	// identify whether the current user has permission to edit the client record
	var p = 0;
	if (record.company_id == globals.guser_com_id)
	{
		p = 1;
		if (guserid$to_sec.group_id == 3)
		{
			p = 0;
		}
	}

	if (p == 1)
	{
		// is the client record AND the user does not have administrator status
		// do nothing;
	}
	else
	{
		// not the client record or the user has administrator status
		var comid = record.company_id;
		var k = 1;
		var sev_id = com_sev_id;
		if ( record.sevid$com_to_sev.f_categories == 1 ) // 7Office client has authorized categories
		{
			forms.catUtility.updateComCatRecords(comid, k, sev_id);
		}
	}
}

And here’s the loop within the Category table:

// called by comUtility.updateComCatRecords

var com_id = arguments[0];
var k = arguments[1];
var sevid = arguments[2];
globals.gint1 = null;
controller.saveData();
globals.gint1 = com_id; 
var gint1 = globals.gint1;

var max = controller.getMaxRecordIndex() + 1;
// max = 10; // for test purposes;

for ( var i = 1 ; i < max ; i++ )
{
	var record = foundset.getRecord(i);
	if ( record.sev_id == sevid )
	{
		var key = record.catkey;
		var key1 = record.catkey1;
	
		if (databaseManager.hasRecords(record.comupdate$cat_to_catitem) == false)	
		{
			forms.catitemUtility.updateComCatRecords(com_id, k, key, key1, sevid);	
		}
	}
}

Morley, I haven’t evaluated your code completely (my answer would be too quik for that :) )…

However if you loop like```
for ( var i=1 ; i <= controller.getMaxRecordIndex() ; i++)


Hope this helps...

Gotcha. Makes sense. Thanks Marcel.