# controller.loadRecords(id)

**URL:** <https://forum.servoy.com/t/controller-loadrecords-id/1249>\
**Category:** Classic Servoy\
**Created:** [February 12, 2004, 3:55pm UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249 "2004-02-12T15:55:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 12, 2004, 3:55pm UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/1 "2004-02-12T15:55:49Z")

</div>

I add records to a foundset and add the id to an array. Later I use that array to print the forms based on that array. I do the following for that. Unfortunately the foundset is bigger than what I defined. What do I do wrong:

```auto
var dataset = arguments[0]; //taken from another foundset into the method
var ID = new Array(dataset.getMaxRowIndex()); //define array

for (var i = 1 ; i <= dataset.getMaxRowIndex(); i++)
{
	if (i > 1)
		controller.duplicateRecord();	//I duplicate this record if i > 1
				
	ID[i-1] = lettersid; //add the id to the array
}

forms.lettersPrint.controller.loadRecords(ID); //call form/records based on arry
forms.lettersPrint.controller.print(false, true);//print records

```

I checked the dataset and the ID array. They both have 3 records in there but printing gives me all records…

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [February 12, 2004, 11:06pm UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/2 "2004-02-12T23:06:11Z")

</div>

What you are trying todo is not possible (but might be a good idea to build)  
Move sample code of loadRecords(…) to see all possibilities of use

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [February 12, 2004, 11:08pm UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/3 "2004-02-12T23:08:33Z")

</div>

first convert the ID’s to a dataset:

var set = databasemanager.convertToDataset(ID);

and use that set in youre load

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 13, 2004, 9:00am UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/4 "2004-02-13T09:00:10Z")

</div>

![:oops:]( "Embarassed") Should/could have know! Thanks guys ‘problemo solvado’…

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 13, 2004, 9:51am UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/5 "2004-02-13T09:51:00Z")

</div>

Well, it looks like there still is an issue. Instead of:

```auto
forms.lettersPrint.controller.loadRecords(ID);
forms.lettersPrint.controller.print(false, true);

```

I now have:

```auto
var set = databaseManager.convertToDataSet(ID);

forms.lettersPrint.controller.loadRecords(set);
forms.lettersPrint.controller.print(false, true);

```

This gives me a set of 2 selected records where the array (ID) and dataset (set) contain 3 records (I doublechecked this)!!!

When I now do:

```auto
var set = databaseManager.convertToDataSet(ID);

forms.letters.controller.loadRecords(set)
forms.lettersPrint.controller.loadRecords(foundset);
forms.lettersPrint.controller.print(false, true);

```

Where the form letters is the original form on which I created the array…  
The result is the expected 3 records?

Do I do something wrong or is this a bug?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [February 13, 2004, 10:06am UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/6 "2004-02-13T10:06:15Z")

</div>

this could als be youre code yes?

```auto
var set = databaseManager.convertToDataSet(ID); 

controller.loadRecords(set) 
forms.lettersPrint.controller.loadRecords(foundset); 
forms.lettersPrint.controller.print(false, true);

```

(so you are in the context of the letters form.. )  
To be sure that you set the same foundset…

what does the maxRecordIndex say when you load the records?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 13, 2004, 11:48am UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/7 "2004-02-13T11:48:56Z")

</div>

Below my factfinding mission:

Here I load the set into the basic form and load the foundset into the print form. All goes well…

```auto
controller.loadRecords(set) 
//controller.getMaxRecordIndex result = 3
forms.lettersPrint.controller.loadRecords(foundset); 
//forms.lettersPrint.controller.getMaxRecordIndex result = 3

```

Here I don’t do a controller.loadRecords() and the foundset = 2. I only print two records…

```auto
//controller.loadRecords(set) 
//controller.getMaxRecordIndex result = 2
forms.lettersPrint.controller.loadRecords(foundset); 
//forms.lettersPrint.controller.getMaxRecordIndex result = 2

```

Here I again don’t do a controller.loadRecords() and the foundset is again 2. When loading the set (and not the foundset) into the print form I again have 3 records but can only print 2???

```auto
//controller.loadRecords(set) 
//controller.getMaxRecordIndex result = 2
forms.lettersPrint.controller.loadRecords(set); 
//forms.lettersPrint.controller.getMaxRecordIndex result = 3

```

In all cases I didn’t use a seperate foundset (check in print form) and checking the print form to use a seperate foundset doesn’t change the result.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [February 16, 2004, 9:36am UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/8 "2004-02-16T09:36:32Z")

</div>

Could you check the default sort on your forms, one of must be using a related field sort with one field being null in the database (and is due to db join for sort not returned)

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 16, 2004, 9:53am UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/9 "2004-02-16T09:53:56Z")

</div>

Hai Jan, thanks for your effort! Just wanted to tell you that…

In this case I don’t use any (default-) sort on both the forms. So that can’t be the issue… I have attached the properties of the forms. Left is the ‘basic’ form right = the ‘print’ form.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [February 20, 2004, 12:47pm UTC](https://forum.servoy.com/t/controller-loadrecords-id/1249/10 "2004-02-20T12:47:04Z")

</div>

we are unable to reproduce this at all, can you sent us your solution or provide a small sample which shows this?
