← servoy magazine

[Challenge] Difference between controller.newRecord() and foundset.newRecord()

  • Challenge

by David Workman
Data Mosaic

Here's a trivia question for you: what are the differences between the controller.newRecord() function and foundset.newRecord() function?

Both functions create a new record. But after that there are some interesting and subtle differences. I'll give you a day or two to think this one through. Feel free to post your thoughts!

Comments (5)

Karel Broer
I'dd say that the main difference would be that controller.newRecord() uses a form controller to create a record. Which means that you could trigger an onLoad, onShow or onRecordSelection method by doing this. That's one one the reasons I prefer to use foundset.newRecord().
Robert Huber
Hello David I like your (trivia) question very much, although I don't think it's trivia. Has someone a really good overview of what the foundset is with all of its characteristics and differences to db content and what's displayed on the human interface? Thanks for the question, I have not a clear answer but I am waiting with interest for the solution :-)
Arup Ranjan Sahoo
Hi David, Both(controller.newRecord() and foundset.newRecord()), will create a new record in the current foundset. But the twist is attached with the 2nd. argument of foundset.newRecord( [addOnTop], [changeSelection]). If the value to changeSelection is false, then it will create a new record but the new record won't be get selected, no onRecordSelection Event etc. get fired(as Karel specified).
Prem Chand Mali
Hi David, I am beginer for servoy. Whatever i learn and see according to that, the only difference between then. controller.newRecord([addOnTop]) taking one argument that is creating record in top or bottom, and about foundset.newRecord( [addOnTop], [changeSelection]) first argument create record on top or bottom, the other argument is used for deciding the selection of record.
Martin
Don't let us wait any longer. A day or two are passed now. Tell us exactly what the difference is.