Here’s the scenario. A method calls for the creation of a new record and then follows that up with some set field instructions. However, if the new record doesn’t load into the current form, you’re corrupting whatever record happens to be in the form.
This problem happens only if there’s just one record previously loaded in the form, and it depends on how that record was loaded. I’ve been unsuccessful in building a small routine which duplicates the issue. But it’s there in my solution in various places.
My workaround has been to loadAllRecords() just ahead of all calls for newRecord(). However that slows down the solution considerably.
Just now Bob Cusick nailed the solution by telling me about the newRecord(true) variant. According to the docs, “Creates a new record on the current form to the top of the foundset.” I’ve changed all my newRecord() commands universally to newRecord(true) and the problem disappears.
I posed this issue to the forum in March and got no responses from anyone. Finally decided to pose it directly to a few select individuals, and Bob caught it. Much, much, much thanks.
RobertMeyer:
this one’s been driving me crazy for days…
thanks!!
Drove me crazy for nearly two months. Am still not clear precisely on what circumstances will cause a new record not to load into the form creating it. Has something to do with a prior loadRecords(relationship) that results in a single record, but I was never able to deliberately create the problem. It just lingers randomly from some previous sequence of user actions.
However using the command newRecord(true) stops it in its tracks. Spread the word.
RobertMeyer:
i have a clue: it always happens to me when i attempt to create a new record in a form just after opening
the solution…
In my experience it happens well after just opening the solution. I’ve seen success the first round of creating a new record, but failure on the second pass. But I’ve also seen it fail the very first time through. Utterly unpredictable.
I’ve not been successful in narrowing the specific circumstances required to cause failure. In all circumstances of failure the form has just a single record loaded. I spent two days trying to set up a demo which would exhibit failure. Demo would always succeed, solution would continue to intermittently fail.
The problem is very serious because failure corrupts good data. In March I couldn’t afford to dick around any further and therefore added a loadAllRecords() just ahead of every newRecord() command. This solved the problem but slowed the solution considerably.
Did I report it? Yes, of course I did. A failure in communication and therefore the problem was not resolved. More recently I privately posted the issue to Bob Cusick and two non-Servoy staff members who have been very helpful in the past. Bob immediately recognized what I was talking about.
Guys, what you tell here ‘well after opening the solution’, makes me wonder if the creation of the new record is done by the user or triggered by an event… If the last is the case: What is that event?
IT2BE:
Guys, what you tell here ‘well after opening the solution’, makes me wonder if the creation of the new record is done by the user or triggered by an event… If the last is the case: What is that event?
In my case it’s triggered by the user clicking on a button which runs a method. No events involved.
I’m having similar problems with creating a new record. The crazy thing for me is that when I step through my scripts with the debugger enabled, it works fine: when the newRecord() method is called, the controller goes to the new record. When I turn off the debugger, the controller stays on whatever record it was on previously, despite the fact that the record is being created. Has anyone else experienced this? Isn’t there some way to go to a newly created record? I thought so, but can’t see to remember it. Thanks in advance for any help or advice.
Jake L
Currently developing on build 328, Java 1.5.0_02-b09 (Windows XP)
Jake_L:
I’m having similar problems with creating a new record. The crazy thing for me is that when I step through my scripts with the debugger enabled, it works fine: when the newRecord() method is called, the controller goes to the new record. When I turn off the debugger, the controller stays on whatever record it was on previously, despite the fact that the record is being created. Has anyone else experienced this? Isn’t there some way to go to a newly created record? I thought so, but can’t see to remember it. Thanks in advance for any help or advice.
Make sure your newRecord() command includes “true” in the brackets. I’m finding that solves the problem.```
newRecord(true);