databaseManager.hasNewRecords(foundset)

Questions, tips and tricks and techniques for scripting in Servoy

databaseManager.hasNewRecords(foundset)

Postby paulc » Wed Aug 11, 2010 12:57 am

Hi,

I am moving from 4.1.7 to 5.1.4 and was wondering if anyone noticed that the databaseManager.hasNewRecords(foundset) no longer works correctly?

My situation is this, I create a new record foundset.newRecord(). This foundset requires that you create another record in another table because it is a superset (one to one relationship). which I do immediately afterwards with foundset.super_set_to_sub_set_record.newRecord().


So

foundset.newRecord [databaseManager.hasNewRecords(foundset) = true]
foundset.super_set_to_sub_set_record.newRecord [ databaseManager.hasNewRecords(foundset) = false databaseManager.hasNewRecords(foundset.super_set_to_sub_set_record) = true ]

This is kind of an issue because I need to validate if the super_set foundset has a new record to set some column data before saving and other data if its only an updated record.

Doesn't really make sense to me that the databaseManager.hasNewRecords(foundset) would be set to false after that because its still a new record that hasn't been saved to the database.

Any ideas?
paulc
 
Posts: 55
Joined: Wed Feb 17, 2010 8:58 pm

Re: databaseManager.hasNewRecords(foundset)

Postby jcompagner » Wed Aug 11, 2010 9:24 am

can you create a case for this?
with a small example?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.hasNewRecords(foundset)

Postby paulc » Thu Aug 12, 2010 12:38 am

Hi Johan,

heres a quick sample case for you. I made a mistake in my initial post. It should be once a new record has been altered, the foundset no longer returns as hasNewRecords

Below is a simple function when clicking a button
Code: Select all
function createNewCustomerHasNewTest(event)
{
  application.output("Before new record: " + databaseManager.hasNewRecords(foundset));
  foundset.newRecord();
  application.output("After new record: " + databaseManager.hasNewRecords(foundset)); 
  foundset.customerid = 'abcd';
  application.output("After alter new record: " + databaseManager.hasNewRecords(foundset));
 
}


Results
Before new record: false
After new record: true
After alter new record: false
paulc
 
Posts: 55
Joined: Wed Feb 17, 2010 8:58 pm

Re: databaseManager.hasNewRecords(foundset)

Postby mboegem » Thu Aug 12, 2010 12:52 am

paulc wrote:It should be once a new record has been altered, the foundset no longer returns as hasNewRecords

I'd say this was an undocument feature :wink:

In order to test whether changes have been made or not on a foundset (or record), use: databaseManager.hasRecordChanges()
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

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

Re: databaseManager.hasNewRecords(foundset)

Postby jcompagner » Thu Aug 12, 2010 9:56 am

you are setting the primary key there, and that results in this behavior.
Will look for a fix.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.hasNewRecords(foundset)

Postby jcompagner » Thu Aug 12, 2010 10:32 am

fixed in 5.2.1
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.hasNewRecords(foundset)

Postby paulc » Thu Aug 12, 2010 5:26 pm

Thanks Marc and Johan for the responses.
paulc
 
Posts: 55
Joined: Wed Feb 17, 2010 8:58 pm


Return to Methods

Who is online

Users browsing this forum: No registered users and 6 guests