# currentcontroller.maxRecordIndex

**URL:** <https://forum.servoy.com/t/currentcontroller-maxrecordindex/101>\
**Category:** Classic Servoy\
**Created:** [June 3, 2003, 7:48am UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101 "2003-06-03T07:48:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 3, 2003, 7:48am UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101/1 "2003-06-03T07:48:21Z")

</div>

This method:

> currentcontroller.recordIndex = currentcontroller.maxRecordIndex

isn’t working anymore! Also in the CRMdemo it isn’t function anymore.

am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [June 3, 2003, 9:05am UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101/2 "2003-06-03T09:05:06Z")

</div>

This is old syntax that shouldn’t be there in the CRM.

Proper syntax:

currentcontroller.recordIndex = currentcontroller.getMaxRecordIndex()

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 3, 2003, 11:15am UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101/3 "2003-06-03T11:15:50Z")

</div>

Oke, that’s fixed.  
but it still does’nt work all the time.

If i open the solution, it works (it goes to the last record) but after I click a field label (sorting!) and my list is sorted, it won’t go to the last record! (total of 10.000 records!)

---

<div class="post-metadata">

**Author:** ![Jan\_Aleman](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jan\_Aleman](https://forum.servoy.com/u/Jan_Aleman)\
**Post date:** [June 3, 2003, 11:36am UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101/4 "2003-06-03T11:36:11Z")

</div>

Why don’t you do an invert sort if you want to go to the last record? In some desktop databases it is very common to go with one click to the last record as all data is always local.In SQL based backends this is not very common and depending on your foundset it can be very expensive. Servoy will by default get the first 200 rows as you might have noticed in the controller. Servoy simply doesnt know what your last record is, you could know by performing a count (servoy even has a function for that) but that can be an expensive operation depending on your amount of data. If you still want to go to your last record anyhow you can do:

```auto
while (controller.recordIndex < controller.getMaxRecordIndex())
{
	controller.recordIndex = controller.getMaxRecordIndex();
}

```

The above isnt a problem if you have 10k rows but I wouldnt recommend it in large tables. It also undermines the true client/server concept of Servoy.

I still recommend the inverse sorting to go to the last record as then you leave the sorting to be done by the backend SQL server that has been optimized to perform this kind of operations.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 3, 2003, 11:46am UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101/5 "2003-06-03T11:46:08Z")

</div>

Oke thanks!  
That makes it clear!

---

<div class="post-metadata">

**Author:** ![Tony\_Adrian](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Tony\_Adrian](https://forum.servoy.com/u/Tony_Adrian)\
**Post date:** [June 3, 2003, 12:16pm UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101/6 "2003-06-03T12:16:09Z")

</div>

I haven’t tried this yet but here’s my knee-jerk thought:

Have Servoy or the backend automatically increment a seperate table every time records are added or deleted. Place the appropriate dataprovider on the form and you would have a live total row count at all times. As I said - I haven’t tried this but it sounds like a good solution.

…row\_count  
employee…48  
invoices…100002  
payments…79000  
customers…590

Add another payment:

…row\_count  
employee…48  
invoices…100002  
payments…79001  
customers…590

My current end users feel secure seeing the total number of records at all times because they are used to it.

I appreciate any thoughts on this.

---

<div class="post-metadata">

**Author:** ![Jan\_Aleman](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jan\_Aleman](https://forum.servoy.com/u/Jan_Aleman)\
**Post date:** [June 3, 2003, 12:36pm UTC](https://forum.servoy.com/t/currentcontroller-maxrecordindex/101/7 "2003-06-03T12:36:26Z")

</div>

Good idea, downside is that you if you add/delete records outside of Servoy it wouldnt reflect a correct count. Also this solution will only work for counts of complete tables what if somebody does a find and has a large foundset.

In many cases you can simply use the count functions Servoy provides:  
getTableCount for an entire count and  
getFoundSetCount for the foundset  
Just make sure you don’t use them on very large tables or buy a very big databaseserver ![;-)]( "Wink")

You could also consider maintaining rowcounts using a trigger on your backend database.
