# new records produce java.lang error

**URL:** <https://forum.servoy.com/t/new-records-produce-java-lang-error/5566>\
**Category:** Classic Servoy\
**Created:** [March 8, 2006, 8:57pm UTC](https://forum.servoy.com/t/new-records-produce-java-lang-error/5566 "2006-03-08T20:57:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmountain](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@gmountain](https://forum.servoy.com/u/gmountain)\
**Post date:** [March 8, 2006, 8:57pm UTC](https://forum.servoy.com/t/new-records-produce-java-lang-error/5566/1 "2006-03-08T20:57:54Z")

</div>

Hi Guys,  
I have included a .doc file to try to show my problem and hopefully it can explain better than I can.

I have a main form that has tab forms in it. When I create a new record using a tab form, the currentcontroller is called (from the main form) and a new record window pops up. It creates a new record, and any information entered in the tab form is put into the database correctly, but then when the information is saved into the database, the information disappears from the form.

Code used to create the record is:

var formName = elements.Employeemain.getSelectedTabFormName();  
if(formName == “Employee”)  
{  
var formName = null;  
currentcontroller.newRecord();  
var userName = security.getUserName();  
forms.Employee.recordcreatedon = application.getTimeStamp();  
forms.Employee.recordcreatedat = application.getTimeStamp();  
forms.Employee.recordcreatedby = userName;  
}

The interesting part is - If I have 200 records loaded (for example) and I do a new record - it inserts it as 201. When the data is saved the 201 is shown as the record I’m on, but no data. If I try to enter data on that screen, then I get the java.lang error.

If I then go to the end of the total foundset and load all records the data shows up as the next number in the index (1692) and the data shows in the form. If I am on the last record in the foundset, and create a new record, then the data disappears until I stop and start the application in order to reread the databases.

I am using Linux Fedora Core 4  
Servoy Server version 2.4.4

We’ve been using this application quite successfully for about 5 months now, and this is a new occurrence. Any help would be greatly appreciated, since I am totally stumped.

Thanks in advance for helping me out.

Graham

[newrecord.doc](https://forum.servoy.com/uploads/short-url/fILFAAeiz51T9EssRmVcbccIR7z.doc) (373 KB)

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [March 9, 2006, 8:36am UTC](https://forum.servoy.com/t/new-records-produce-java-lang-error/5566/2 "2006-03-09T08:36:10Z")

</div>

What is the exact error that you get? Could you post the full error from the log?

But I also find the approach of using currentcontroller a bit strange (what happens for example if currentcontroller points to some other form). Why don’t you write

```auto
var formName = elements.Employeemain.getSelectedTabFormName();
if(formName == "Employee")
{
forms[formName].controller.newRecord();
forms[formName].recordcreatedon = application.getTimeStamp();
forms[formName].recordcreatedat = application.getTimeStamp();
forms[formName].recordcreatedby = security.getUserName();
}

```

or even nicer

```auto
if(formName == "Employee")
{
var newRecord = forms[formName].foundset.getRecord(forms[formName].foundset.newRecord(false, true));
newRecord.recordcreatedon = application.getTimeStamp();
newRecord.recordcreatedat = application.getTimeStamp();
newRecord.recordcreatedby = security.getUserName();
}

```

Additionally you could consider using autoenter properties for creation date and creation user name. Just check out the auto enter properties of the dataproviders used.

---

<div class="post-metadata">

**Author:** ![gmountain](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@gmountain](https://forum.servoy.com/u/gmountain)\
**Post date:** [March 9, 2006, 5:12pm UTC](https://forum.servoy.com/t/new-records-produce-java-lang-error/5566/3 "2006-03-09T17:12:28Z")

</div>

Thanks Patrick,  
I appreciate your advice. The code you suggested works in the developer, but not in the client. I enter the new record in the client, and it creates a newrecord, but nothing shows on the form once the data is saved. I have to reload the application to get the data to show in the form.

I looked at the log, but there are no errors or information other than the output statements I have inserted to try to figure this out.

I no longer get a java.lang error though when I enter data into the new record.

Here’s the relevant output from the log.

Java Web Start 1.4.2\_08 Console, started Thu Mar 09 10:00:39 MST 2006  
Java 2 Runtime Environment: Version 1.5.0\_06 by Sun Microsystems Inc.  
Logging to file: C:\Servoy\javaclient.log  
Starting Servoy from C:\Documents and Settings\grahamm\Desktop  
Servoy R2 2.2.4 build-336 on Windows XP using Java 1.5.0\_06

Username = mountain  
user:admin  
user:ames  
user:ami  
user:bell  
user:bernick  
user:brekke  
user:burris  
user:cloninger  
user:comer  
user:demaria  
user:dempsey  
user:garcia  
user:green  
user:gross  
user:harrop  
user:ho  
user:hoge  
user:judy  
user:king  
user:kosley  
user:kramer  
user:lathrop  
user:lewis  
user:mcauley  
user:mckie  
user:meshek  
user:mountain  
group: Master  
user:pantyukh  
user:pendergrass  
user:pomeroy  
user:pomper  
user:regnier  
user:richard  
user:rush  
user:sawyer  
user:schubert  
user:sperry  
user:steffen  
user:swenson  
user:takamura  
user:zellers  
Username = mountain  
Username = mountain  
Username = mountain

Graham

---

<div class="post-metadata">

**Author:** ![gmountain](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@gmountain](https://forum.servoy.com/u/gmountain)\
**Post date:** [March 9, 2006, 5:41pm UTC](https://forum.servoy.com/t/new-records-produce-java-lang-error/5566/4 "2006-03-09T17:41:56Z")

</div>

Hi Patrick,  
I added an extra statement to the code at the end to show the Employee\_Main form, and that seems to have solved the data showing problem.

I appreciate your time and advice. I’m learning as I go, so I take all the advice I can from the experts.

Thanks again for you time and advice.

Graham
