Backup of new records

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Backup of new records

Postby deezzub » Mon Oct 07, 2013 10:55 am

Because I needed a "Backup of edited records", I saved them into a array using the method: databaseManager.getEditedRecords( fs ). This also includes the new created records. The problem now is, that the JSRecord method: getChangedData( ) only serves data for edited records that have an old value, but not for new records.

Why this method does not provide data for new records? I think, it would be useful if for new records the old value is just empty.
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: Backup of new records

Postby mboegem » Mon Oct 07, 2013 1:50 pm

you can just use databaseManager.hasNewRecords(record).
If this returns true, loop over the dataproviders in your record and use the actual values.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Backup of new records

Postby deezzub » Mon Oct 07, 2013 2:55 pm

mboegem wrote:you can just use databaseManager.hasNewRecords(record).
If this returns true, loop over the dataproviders in your record and use the actual values.


I found this solution, but I think it would be simpler if I could get the new values by the getChangedData( ) method, because I already looped through the changed / edited records. Now I have to do two different things to backup the edited and new created records, but it would be possible to do this, if the method would provide the new values also for new records.

The source problem was that I want to omit a record, but it seems that the omitRecord( ) does not not work if another record is already changed. So I'm in the need to revert all changes to the old values, omit a record and then revert the edited records to the new values.

But if the user created a new record the new record is lost, because I get no changed data for new records.

I'm in the need to omit a record, because of this problem.
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: Backup of new records

Postby mboegem » Mon Oct 07, 2013 3:19 pm

deezzub wrote:Now I have to do two different things to backup the edited and new created records


If everything was as easy as doing it all from one function, I think we wouldn't even need programmers... :-)

Anyway, you can still use the same loop to go through your records either edited or new.
At each iteration, test whether the record is new or not:
- true: loop over the columns in your table and do whatever you want to do.
- false: execute your current code.

Instead of waiting for a 'one key' solution I'd suggest to just write this piece of code.
It will take you probably 10 minutes max. to do this and your problem is solved...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 18 guests

cron