duplicate then restore a record?

Let’s say I have a variable that contains an entire record I want to add to a table. Is there way to add it that doesn’t require me to assign each column one by one to its respective dataprovider?

Example:

let’s say I have a var called editedRecord which I created using

var editedRecord = foundset.getRecord()

Now I want to add that record to my table. Is there a way to do that that doesn’t involve this:

field1 = editedRecord.field1
field2 = editedRecord.field2
etc.

but rather a single command that moves all columns over at once?

Not that I know of.

Why are you doing this? Is this for when you have turned off auto-save and then edited the record and you want to now save? If so, then use controller.saveData() or if you are using 3.0 - then use databaseManager.saveData().

Hope this helps.

yes, you can! :-)

you can do this by copyMatchingColumns (under database-manager)

Bob, to answer your question of why I want to do this, I am writing a document about Servoy and one of the topics is how in Servoy do you verify the uniquess of a new or edited record before saving it.

I know there are other ways of doing this, but I am exploring this approach:

user adds a record & hits a “save” button
I backup the record in a var using getRecord()
do a find()/search() on the unique column to see if there are any dups in the table. This will wipe out the current foundset, causing my new record to be lost (hence the backup)
Now I restore the backed up record and if it was found to be unique, I save it. If not, I tell the user something’s wrong.


Alternate approaches include using an SQL query (which won’t disrupt the foudnset), or using a global relation and getSize(), but I’m trying to validate the approach taken above.

Thanks - I’ll check out copyMatchingColumns