databaseManager.hasNewRecords(foundset)

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?

can you create a case for this?
with a small example?

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

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:
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()

you are setting the primary key there, and that results in this behavior.
Will look for a fix.

fixed in 5.2.1

Thanks Marc and Johan for the responses.